Skip to content

Commit

Permalink
Merge pull request #2 from pmtao/master
Browse files Browse the repository at this point in the history
增强主题可配置特性
  • Loading branch information
sumimakito committed Oct 31, 2017
2 parents 45ed030 + 4991878 commit 03afc2f
Show file tree
Hide file tree
Showing 24 changed files with 1,872 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.DS_Store
node_modules
tmp
78 changes: 73 additions & 5 deletions README.md
Expand Up @@ -11,21 +11,48 @@ hexo-theme-Typography

```bash
cd hexo # cd into the root directory of your Hexo blog
npm install --save hexo-renderer-jade hexo-generator-archive

npm install --save hexo-renderer-jade hexo-generator-archive hexo-generator-category-enhance hexo-generator-feed hexo-generator-tag

npm uninstall --save hexo-generator-category # use hexo-generator-category-enhance instead

git clone https://github.com/SumiMakito/hexo-theme-typography themes/typography
cd theme/typography

cd themes/typography

npm install
```

> You can skip the second line provided you have already installed `hexo-renderer-jade` and `hexo-generator-archive` in your Hexo blog's root directory.
> You can skip the second line provided you have already installed `hexo-renderer-jade` , `hexo-generator-category-enhance `, `hexo-generator-feed`, `hexo-generator-tag` and `hexo-generator-archive` in your Hexo blog's root directory.
### Modify the config file

Find `theme:` in your `_config.yml` at the root directory of your Hexo blog, and change that line into `theme: typography`, then add these lines:
Find `theme:` in your `_config.yml` at the root directory of your Hexo blog, and change that line into `theme: typography`, set `language` to `zh-cn` or `en` as you like , then add these lines:

```yaml
# Generate archive page
archive_generator:
per_page: 0

# Generate categories index page and each category page
category_generator:
per_page: 10
enable_index_page: true

# Generate tags index page and each tag page
tag_generator:
per_page: 10
enable_index_page: true

# Generator atom feed for you website
feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: ' '
```

## Update
Expand Down Expand Up @@ -59,6 +86,16 @@ It is possible to control the length for all the summaries on the index page by

e.g. `truncate_len: 160`

### Set up theme color style

You can choose two color styles:
- light
- dark

``` yaml
themeStyle: light # light, dark
```

### Set up the comment service

The comment box is a place for readers to exchange their ideas with the author. Typography has integrated two 3rd-party comment services, and they are ready to use at any time.
Expand All @@ -69,6 +106,37 @@ e.g. `disqus: disqus_shortname` OR `livere: livere_data_uid`

> Do not use two comment services at the same time, or the post will be followed by two comment boxes. Just leave blank for the rest of the comment service-related options.
### Set up pagination style

You can choose two styles to show pagination:
- simple: just show previous page and next page link
- show page count: except page link, still show what current page number is and how many pages in total, set below to true in Typography's _config.yml:

```yaml
showPageCount: true
```

### Show categories and tags links behind post title

You can choose to show categories and tags links behind post title in index and post page:

``` yaml
showCategories: true
showTag: true
```
### Set up website favicon

Prepare `favicon.png` file and put in `themes/typography/source/images/favicon.png`

### Set up google analytics id

Open file: `themes/typography/source/js/google-analytics.js`

Find this line:
`ga('create', 'UA-73442912-1', 'auto');`

Change ` 'UA-73442912-1'` to your google analytics id

### SEO-friendly meta description tag

Typography gives you the chance to insert unique SEO-friendly meta description tags for different posts. Also, it is handy. Just add a new line in the head section of your post:
Expand Down Expand Up @@ -113,7 +181,7 @@ github: user_name
Typography uses `node-sass` and `scss-compile` to generate `.css` files for styling. We have provided several options such as background and foreground colors for you to choose. When your editing is finished, don't forget to run the commands below to re-generate the `.css` files:

```bash
cd theme/typography
cd themes/typography
npm run scss-compile
```

Expand Down
12 changes: 11 additions & 1 deletion _config.yml
Expand Up @@ -12,4 +12,14 @@ github: # user_name
# Please do not use the two services at the same time.
livere: # [data-uid] on livere.com
disqus: # [short_name] on disqus.com
dove: # For fun ONLY. Set to true to 'disable' comments on your site.
dove: # For fun ONLY. Set to true to 'disable' comments on your site.

# Set true to show current page number and total page count beyond page link.
showPageCount: true

# Set true to show category or tags behind post title.
showCategories: true
showTag: true

# Choose theme style
themeStyle: dark # light, dark
7 changes: 6 additions & 1 deletion languages/en.yml
Expand Up @@ -11,4 +11,9 @@ Tags: Tags
About: About
Links: Links
Comments: Comments
posted_at: Posted at
posted_at: Posted at
TagCount: '%d post'
ArchiveCount: '%d post'
CategoriesCount: '%d post'
PageCount: '%d pages total'
PageNumber: 'Page %d'
7 changes: 6 additions & 1 deletion languages/zh-cn.yml
Expand Up @@ -11,4 +11,9 @@ Tags: 标签
About: 关于
Links: 链接
Comments: 评论
posted_at: 发布于
posted_at: 发布于
TagCount: '%d 篇'
ArchiveCount: '%d 篇'
CategoriesCount: '%d 篇'
PageCount: '共 %d 页'
PageNumber: '第 %d 页'
7 changes: 6 additions & 1 deletion languages/zh-tw.yml
Expand Up @@ -11,4 +11,9 @@ Tags: 標籤
About: 關於
Links: 連結
Comments: 評論
posted_at: 發佈於
posted_at: 發佈於
TagCount: '%d 篇'
ArchiveCount: '%d 篇'
CategoriesCount: '%d 篇'
PageCount: '共 %d 頁'
PageNumber: '第 %d 頁'
7 changes: 5 additions & 2 deletions layout/archive.jade
Expand Up @@ -11,7 +11,10 @@ block content
.autopagerize_page_element: .content
.archive.animated.fadeInDown
ul.list-with-title
p.post-title
!= __("Archive") + ' ' + __('ArchiveCount', site.posts.length)
include mixins
+postList()
include mixins
+make_pager(__('prev'), __('next'))
if config.archive_generator.per_page
include mixins
+make_pager(__('prev'), __('next'))
18 changes: 18 additions & 0 deletions layout/category-index.jade
@@ -0,0 +1,18 @@
extends partial/layout

block site_title
!= __("Categories") + " · " + config.title

block description
- var desc = __("Categories")+ ' - ' + config.title;
meta(name="description", content=desc)

block content
.autopagerize_page_element: .content
.archive.animated.fadeInDown
ul.list-with-title
p.post-title
!= __("Categories")
include mixins
+categoryList()

4 changes: 4 additions & 0 deletions layout/category.jade
Expand Up @@ -11,5 +11,9 @@ block content
.autopagerize_page_element: .content
.archive.animated.fadeInDown
ul.list-with-title
p.post-title
!= __("Categories")+' ' + page.category
include mixins
+postList()
include mixins
+make_pager(__('prev'), __('next'))
79 changes: 59 additions & 20 deletions layout/mixins.jade
Expand Up @@ -7,20 +7,31 @@ mixin make_post(item, is_detail)
a(href= url_for(item.path))= item.title
p.post-meta
span.date.meta-item!=__("posted_at")+" " + date(item.date, 'YYYY-MM-DD')
if !is_detail
if theme.duoshuo || theme.disqus
span.meta-item
i.fa.fa-comment-o
span  
a(href= url_for(item.path + "#comments"))= __('Comments')
if item.tags.length > 0
span.meta-item
i.fa.fa-tag
span  
- item.tags.sort('posts').each(function(item) {
a.a-tag(href=config.root + item.path, title= item.name)= item.name
span  
- });
if theme.duoshuo || theme.disqus
span.meta-item
i.fa.fa-comment-o
span  
a(href= url_for(item.path + "#comments"))= __('Comments')
if theme.showCategories
if item.categories
if item.categories.length > 0
span.meta-item
i.fa.fa-folder
span  
- item.categories.sort('posts').each(function(item) {
a.a-tag(href=config.root + item.path, title= item.name)= item.name
span  
- });
if theme.showTag
if item.tags
if item.tags.length > 0
span.meta-item
i.fa.fa-tag
span  
- item.tags.sort('posts').each(function(item) {
a.a-tag(href=config.root + item.path, title= item.name)= item.name
span  
- });
if is_detail
p.post-abstract!= item.content
else
Expand All @@ -30,10 +41,10 @@ mixin make_page_links()
if site.pages
- site.pages.each(function (page) {
li
if is_current(page.path)
a.current(href=config.root+page.path)= page.title
else
a(href=config.root+page.path)= page.title
if is_current(page.path)
a.current(href=config.root+page.path)= page.title
else
a(href=config.root+page.path)= page.title
- });


Expand All @@ -42,12 +53,16 @@ mixin make_pager()
- var next = page.next_link
.pagination.no-margin-bottom
p.clearfix
if theme.showPageCount
p
!= ' ' + __('PageNumber', page.current) + ' / ' + __('PageCount', page.total) + ' '
|  
if page.prev
span.pre.pagbuttons
i.fa.fa-angle-double-right
i.fa.fa-angle-double-left
|  
a(role="navigation",href=url_for(prev))= __('prev')
span  
span  
if page.next
span.next.pagbuttons
a(role="navigation",href=url_for(next))= __('next')
Expand Down Expand Up @@ -81,3 +96,27 @@ mixin postList()
div.post-time
span.ar-date= date(item.date, 'MM-DD')
- })

mixin tagList()
.archive
ul.listing
- site.tags.each(function (item) {
.listing-item
.listing-post
p.post-title
a(href= url_for(item.path), title= item.name)= item.name
span.date.meta-item
!= __('TagCount', item.posts.length)
- })

mixin categoryList()
.archive
ul.listing
- site.categories.each(function (item) {
.listing-item
.listing-post
p.post-title
a(href= url_for(item.path), title= item.name)= item.name
span.date.meta-item
!= __('CategoriesCount', item.posts.length)
- })
8 changes: 4 additions & 4 deletions layout/partial/footer.jade
Expand Up @@ -3,10 +3,10 @@ footer
p © 
!=currYear
|  
a(target="_blank", href=config.url)!=theme.author ? theme.author : config.author ? config.author : config.title
a(target="_blank", href=config.url, rel="noopener noreferrer")!=theme.author ? theme.author : config.author ? config.author : config.title
p Theme 
a(target="_blank", href="https://github.com/SumiMakito/hexo-theme-typography") Typography
a(target="_blank", href="https://github.com/SumiMakito/hexo-theme-typography", rel="noopener noreferrer") Typography
|  by 
a(target="_blank", href="https://www.keep.moe") Makito
a(target="_blank", href="https://www.keep.moe", rel="noopener noreferrer") Makito
p Proudly published with 
a(target="_blank", href="https://hexo.io") Hexo
a(target="_blank", href="https://hexo.io", rel="noopener noreferrer") Hexo
9 changes: 6 additions & 3 deletions layout/partial/head.jade
Expand Up @@ -18,9 +18,12 @@ meta(content="black",name="apple-mobile-web-app-status-bar-style")
meta(content="telephone=no",name="format-detection")

meta(name="renderer",content="webkit")
link(rel="short icon", href="/favicon/favicon.ico",type="image/x-icon")
link(rel="short icon", href="/images/favicon.png",type="image/x-icon")
link(rel="stylesheet", href= url_for('css/bootstrap.min.css'))
link(rel="stylesheet", href= url_for('css/font-awesome.min.css'))
link(rel="stylesheet", href= url_for('css/typography-custom-font.css'))
link(rel="stylesheet", href= url_for('css/style.css'))
//- link(rel="stylesheet", href= url_for('css/typography-custom-font.css'))
if theme.themeStyle == "white"
link(rel="stylesheet", href= url_for('css/style.css'))
if theme.themeStyle == "dark"
link(rel="stylesheet", href= url_for('css/style-dark.css'))
link(rel="alternate" type="application/atom+xml" title="ATOM 1.0" href="/atom.xml")
2 changes: 1 addition & 1 deletion layout/partial/layout.jade
Expand Up @@ -10,7 +10,7 @@ html(lang="zh-CN")
div#main-container.col-sm-9.col-xs-12.main-container.invisible

block content
div.visible-xs
div.visible-xs.site-bottom-footer
include footer


Expand Down

0 comments on commit 03afc2f

Please sign in to comment.