Skip to content

Commit

Permalink
Templates for homepage and markdown posts.
Browse files Browse the repository at this point in the history
Signed-off-by: HE, Tao <sighingnow@gmail.com>
  • Loading branch information
sighingnow committed Apr 28, 2019
1 parent e18e0ce commit 4c29410
Show file tree
Hide file tree
Showing 16 changed files with 479 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
layout: home
---

<style type="text/css" media="screen">
.container {
margin: 10px auto;
max-width: 600px;
text-align: center;
}
h1 {
margin: 30px 0;
font-size: 4em;
line-height: 1;
letter-spacing: -1px;
}
</style>

<div class="container">
<h1>404</h1>

<p><strong>Page not found :(</strong></p>
<p>The requested page could not be found.</p>
</div>
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Jekyll GitBook

Make Jelly site have a GitBook look!

## Demo

[https://sighingnow.github.io/jekyll-gitbook](https://sighingnow.github.io/jekyll-gitbook)

## Why Jekyll with GitBook

GitBook is an amazing frontend style to present and organize contents (such as book chapters
and blogs) on Web. The typical to deploy GitBook at [Github Pages](https://pages.github.com/)
is building HTML files locally and then push to Github repository, usually to the `gh-pages`
branch. It's quite annoying to repeat such workload and make it hard for people do version
control via git for when there are generated HTML files to be staged in and out.

This theme takes style definition out of generated GitBook site and provided the template
for Jekyll to rendering markdown documents to HTML, thus the whole site can be deployed
to Github Pages without generating and uploading HTML bundle every time when there are
changes to the original repo.

## How to Get Started

This theme can be used just as other [Jekyll themes][1].

Fork this repository and add your markdown posts to the `_posts` folder.

[2]: https://pages.github.com
[2]: https://pages.github.com/themes
41 changes: 41 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Configurations
title: Jekyll Gitbook
longtitle: Jekyll Gitbook
author: HE Tao
email: sighingnow@gmail.com
description: >
Build Jekyll site with the GitBook style.
version: 1.0
gitbook_version: 3.2.3

url: 'https://sighingnow.github.io/jekyll-gitbook'
baseurl: ''
rss: RSS

# markdown render engine.
markdown: kramdown
kramdown:
auto_ids: true
input: GFM
math_engine: mathjax
smart_quotes: lsquo,rsquo,ldquo,rdquo
toc_levels: 1..6
syntax_highlighter: rouge
syntax_highlighter_opts:
guess_lang: true

markdown_ext: markdown,mkdown,mkdn,mkd,md

# Permalinks
permalink: /:categories/:year-:month-:day-:title:output_ext

exclude:
- _drafts

destination: ./_site
incremental: false
regenerate: true

plugins:
- jemoji
33 changes: 33 additions & 0 deletions _includes/body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
{% if page.title %}
<a href="." >{{ page.title | escape }}</a>
{% else %}
<a href="." >{{ site.title | escape }}</a>
{% endif %}
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">

{% if page.title %}
<h1 id="{{ page.id }}">{{ page.title | escape }}</h1>
{% else %}
<h1 id="{{ page.id }}">{{ site.title | escape }}</h1>
{% endif %}

{{ content }}
</section>
</div>

<!-- {%- include search.html -%} -->
</div>
</div>
</div>
</div>
10 changes: 10 additions & 0 deletions _includes/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script src="{{site.url}}/gitbook/gitbook.js"></script>
<script src="{{site.url}}/gitbook/theme.js"></script>

<script src="{{site.url}}/gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
<script src="{{site.url}}/gitbook/gitbook-plugin-sharing/buttons.js"></script>

<!-- <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../gitbook/gitbook-plugin-search/search.js"></script> -->
34 changes: 34 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">

{%- if page.title -%}
<title>{{ page.title | escape }} · {{ site.title | escape }}</title>
{%- else -%}
<title>{{ site.title | escape }}</title>
{%- endif -%}

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="{{site.description}}">

{%- if site.gitbook_version -%}
<meta name="generator" content="Jekyll (using style of GitBook {{ site.gitbook_version | escape }})">
{%- else -%}
<meta name="generator" content="Jekyll (using style of GitBook)">
{%- endif -%}

{%- if site.author -%}
<meta name="author" content="{{ site.author | escape }}">
{%- endif -%}

<link rel="stylesheet" href="{{site.url}}/gitbook/style.css">
<link rel="stylesheet" href="{{site.url}}/gitbook/gitbook-plugin-fontsettings/website.css">
<!-- <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css"> -->

<link rel="stylesheet" href="{{site.url}}/gitbook/rouge-highlight-colorful.css">

<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="{{site.url}}/gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="{{site.url}}/gitbook/images/favicon.ico" type="image/x-icon">
22 changes: 22 additions & 0 deletions _includes/metadata-home.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"page": {
"title": "Introduction",
"level": "1.1",
"depth": 1,
{% assign reversed_posts = site.posts | reverse %}

{% if reversed_posts %}
"next": {
"title": "{{reversed_posts.first.title}}",
"level": "1.2",
"depth": 1,
"path": "{{reversed_posts.first.path}}",
"ref": "{{reversed_posts.first.path}}",
"articles": []
},
{% endif %}
"dir": "ltr"
},

{%- include metadata.json.tpl -%}
}
20 changes: 20 additions & 0 deletions _includes/metadata-post.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"page": {
"title": "Introduction",
"level": "1.1",
"depth": 1,
{% if page.next %}
"next": {
"title": "{{page.next.title}}",
"level": "1.2",
"depth": 1,
"path": "{{page.next.path}}",
"ref": "{{page.next.path}}",
"articles": []
},
{% endif %}
"dir": "ltr"
},

{%- include metadata.json.tpl -%}
}
82 changes: 82 additions & 0 deletions _includes/metadata.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"config": {
"plugins": ["fontsettings", "highlight", "livereload", "lunr", "search", "sharing", "theme-default", "livereload"],
"styles": {
"ebook": "styles/ebook.css",
"epub": "styles/epub.css",
"mobi": "styles/mobi.css",
"pdf": "styles/pdf.css",
"print": "styles/print.css",
"website": "styles/website.css"
},
"pluginsConfig": {
"fontsettings": {
"family": "sans",
"size": 2,
"theme": "white"
},
"highlight": {},
"livereload": {},
"lunr": {
"ignoreSpecialCharacters": false,
"maxIndexSize": 1000000
},
"search": {},
"sharing": {
"all": ["facebook", "google", "twitter", "weibo", "instapaper"],
"facebook": true,
"google": false,
"instapaper": false,
"twitter": true,
"vk": false,
"weibo": false
},
"theme-default": {
"showLevel": false,
"styles": {
"ebook": "styles/ebook.css",
"epub": "styles/epub.css",
"mobi": "styles/mobi.css",
"pdf": "styles/pdf.css",
"print": "styles/print.css",
"website": "styles/website.css"
}
}
},
"theme": "default",
"author": "Tao He",
"pdf": {
"pageNumbers": true,
"fontSize": 12,
"fontFamily": "Arial",
"paperSize": "a4",
"chapterMark": "pagebreak",
"pageBreaksBefore": "/",
"margin": {
"right": 62,
"left": 62,
"top": 56,
"bottom": 56
}
},
"structure": {
"langs": "LANGS.md",
"readme": "README.md",
},
"variables": {},
"title": "{{site.title}}",
"language": "en",
"gitbook": "*"
},
"file": {
"path": "{{ page.path }}",
"mtime": "{{ page.date }}",
"type": "markdown"
},
"gitbook": {
"version": "{{site.url}}",
"time": "{{site.time}}"
},
"basePath": "{{site.url}}",
"book": {
"language": ""
}
9 changes: 9 additions & 0 deletions _includes/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
42 changes: 42 additions & 0 deletions _includes/toc-date.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
{% if page.url == "/index.html" or page.url == "/" %}
<li class="chapter active" data-level="1.1" data-path="{{site.url}}">
{% else %}
<li class="chapter" data-level="1.1" data-path="{{site.url}}">
{% endif %}
<a href="{{site.url}}">
{{ site.title | escape }}
</a>
</li>

<li class="divider"></li>

{% assign reversed_posts = site.posts | reverse %}

{% for post in reversed_posts %}
{% if page.url == post.url %}
<li class="chapter active" data-level="1.2" data-path="{{post.url}}">
{% else %}
<li class="chapter" data-level="1.1" data-path="{{post.url}}">
{% endif %}
<a href="{{post.url}}">
{{ post.title | escape }}
</a>
</li>
{% endfor %}

<li class="divider"></li>

<li>
<a href="https://github.com/sighingnow/jekyll-gitbook" target="blank" class="gitbook-link">
Fork it Now!
</a>
</li>
</ul>
</nav>
</div>
Loading

0 comments on commit 4c29410

Please sign in to comment.