Templates for homepage and markdown posts.

Signed-off-by: HE, Tao <sighingnow@gmail.com>
This commit is contained in:
HE, Tao 2019-04-28 19:15:43 +08:00
parent e18e0cee7e
commit 4c29410efa
No known key found for this signature in database
GPG Key ID: E1C05D3ACA574FD9
16 changed files with 479 additions and 0 deletions

24
404.html Normal file
View File

@ -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
README.md Normal file
View File

@ -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
_config.yml Normal file
View File

@ -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
_includes/body.html Normal file
View File

@ -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
_includes/footer.html Normal file
View File

@ -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
_includes/head.html Normal file
View File

@ -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">

View File

@ -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 -%}
}

View File

@ -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 -%}
}

View File

@ -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
_includes/search.html Normal file
View File

@ -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
_includes/toc-date.html Normal file
View File

@ -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>

41
_layouts/home.html Normal file
View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html lang="en" >
<head>
{%- include head.html -%}
{% assign reversed_posts = site.posts | reverse %}
{% if reversed_posts %}
<link rel="next" href="{{reversed_posts.first.url}}" />
{% endif %}
</head>
<body>
<div class="book">
{%- include toc-date.html -%}
<div class="book-body">
{%- include body.html -%}
{% if reversed_posts %}
<a href="{{reversed_posts.first.url}}" class="navigation navigation-next navigation-unique" aria-label="Next page: {{reversed_posts.first.title}}">
<i class="fa fa-angle-right"></i>
</a>
{% endif %}
</div>
<!-- {%- include search.html -%} -->
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({%- include metadata-home.json.tpl -%});
});
</script>
</div>
{%- include footer.html -%}
</body>
</html>

53
_layouts/post.html Normal file
View File

@ -0,0 +1,53 @@
<!DOCTYPE HTML>
<html lang="en" >
<head>
{%- include head.html -%}
{% if page.previous %}
<link rel="prev" href="{{page.previous.url}}" />
{% else %}
<link rel="prev" href="{{site.url}}" />
{% endif %}
{% if page.next %}
<link rel="next" href="{{page.next.url}}" />
{% endif %}
</head>
<body>
<div class="book">
{%- include toc-date.html -%}
<div class="book-body">
{%- include body.html -%}
{% if page.previous %}
<a href="{{page.previous.url}}" class="navigation navigation-prev navigation-unique" aria-label="Previous page: {{page.previous.title}}">
<i class="fa fa-angle-left"></i>
</a>
{% else %}
<a href="{{site.url}}" class="navigation navigation-prev navigation-unique" aria-label="Previous page: {{site.title}}">
<i class="fa fa-angle-left"></i>
</a>
{% endif %}
{% if page.next %}
<a href="{{page.next.url}}" class="navigation navigation-next navigation-unique" aria-label="Next page: {{page.next.title}}">
<i class="fa fa-angle-right"></i>
</a>
{% endif %}
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({%- include metadata-post.json.tpl -%});
});
</script>
</div>
{%- include footer.html -%}
</body>
</html>

20
_posts/2019-04-27-why.md Normal file
View File

@ -0,0 +1,20 @@
---
title: Why Jekyll with GitBook
author: Tao He
date: 2019-04-27
category: Jekyll
layout: post
---
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][1]
is building HTML files locally and then push to Github repository, usually to the `gh-pages`
branch. However, 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][1] without generating and uploading HTML bundle every time when there are
changes to the original repository.
[1]: https://pages.github.com

View File

@ -0,0 +1,14 @@
---
title: How to Get Started
author: Tao He
date: 2019-04-28
category: Jekyll
layout: post
---
This theme can be used just as other [Jekyll themes][1].
Fork this repository and add your markdown posts to the `_posts` folder, then
push to your own Github repository. No need to push generated HTML bundle.
[1]: https://pages.github.com/themes

5
index.md Normal file
View File

@ -0,0 +1,5 @@
---
layout: home
---
Make Jelly site have a GitBook look!