feat: config to show more post meta

word count and read time
This commit is contained in:
olOwOlo 2017-09-11 23:15:13 +08:00
parent 10eacc0066
commit 6879d8e3d3
No known key found for this signature in database
GPG key ID: 456394B6E7A15EA6
12 changed files with 45 additions and 18 deletions

View file

@ -16,6 +16,10 @@ categories = "分类"
reward = "赞赏支持" reward = "赞赏支持"
seeMarkDown = "查看本文 Markdown 版本 »" seeMarkDown = "查看本文 Markdown 版本 »"
[posts.header]
wordCount = "约 %d 字"
readingTime = "预计阅读 %d 分钟"
[copyright] [copyright]
author = "文章作者" author = "文章作者"
lastMod = "上次更新" lastMod = "上次更新"

View file

@ -16,6 +16,10 @@ categories = "Categories"
reward = "Reward" reward = "Reward"
seeMarkDown = "The Markdown version »" seeMarkDown = "The Markdown version »"
[posts.header]
wordCount = "%d word"
readingTime = "%d min read"
[copyright] [copyright]
author = "Author" author = "Author"
lastMod = "LastMod" lastMod = "LastMod"

View file

@ -16,6 +16,10 @@ categories = "分类"
reward = "赞赏支持" reward = "赞赏支持"
seeMarkDown = "查看本文 Markdown 版本 »" seeMarkDown = "查看本文 Markdown 版本 »"
[posts.header]
wordCount = "约 %d 字"
readingTime = "预计阅读 %d 分钟"
[copyright] [copyright]
author = "文章作者" author = "文章作者"
lastMod = "上次更新" lastMod = "上次更新"

View file

@ -51,6 +51,9 @@ copyright = "" # default: author.name ↓ # 默认为下面配
# paginate of archives, tags and categories # 归档、标签、分类每页显示的文章数目 # paginate of archives, tags and categories # 归档、标签、分类每页显示的文章数目
archive-paginate = 3 archive-paginate = 3
# show word count and read time ? # 是否显示字数统计与阅读时间
moreMeta = true
# 一些全局开关,你可以在每一篇内容的 front matter 中单独关闭某些选项 # 一些全局开关,你可以在每一篇内容的 front matter 中单独关闭某些选项
# Some global options, you can close something in front matter. # Some global options, you can close something in front matter.
toc = true # 是否开启目录 toc = true # 是否开启目录

View file

@ -16,6 +16,10 @@ categories = "Categories"
reward = "Reward" reward = "Reward"
seeMarkDown = "The Markdown version »" seeMarkDown = "The Markdown version »"
[posts.header]
wordCount = "%d word"
readingTime = "%d min read"
[copyright] [copyright]
author = "Author" author = "Author"
lastMod = "LastMod" lastMod = "LastMod"

View file

@ -6,9 +6,7 @@
<h1 class="post-title">{{ .Title }}</h1> <h1 class="post-title">{{ .Title }}</h1>
<div class="post-meta"> <div class="post-meta">
<span class="post-time"> <span class="post-time"> {{ .Date.Format "2006-01-02" }} </span>
{{ .Date.Format "2006-01-02" }}
</span>
{{ with .Params.categories -}} {{ with .Params.categories -}}
<div class="post-category"> <div class="post-category">
{{ range . -}} {{ range . -}}
@ -16,6 +14,10 @@
{{- end }} {{- end }}
</div> </div>
{{- end }} {{- end }}
{{ if .Site.Params.moreMeta -}}
<span class="more-meta"> {{ printf $lang.posts.header.wordCount .WordCount }} </span>
<span class="more-meta"> {{ printf $lang.posts.header.readingTime .ReadingTime }} </span>
{{- end }}
</div> </div>
</header> </header>

View file

@ -3,9 +3,7 @@
<header class="post-header"> <header class="post-header">
<h1 class="post-title"><a class="post-link" href="{{ .URL }}">{{ .Title }}</a></h1> <h1 class="post-title"><a class="post-link" href="{{ .URL }}">{{ .Title }}</a></h1>
<div class="post-meta"> <div class="post-meta">
<span class="post-time"> <span class="post-time"> {{ .Date.Format "2006-01-02" }} </span>
{{ .Date.Format "2006-01-02" }}
</span>
{{ with .Params.categories -}} {{ with .Params.categories -}}
<div class="post-category"> <div class="post-category">
{{ range . -}} {{ range . -}}
@ -13,6 +11,10 @@
{{- end }} {{- end }}
</div> </div>
{{- end }} {{- end }}
{{ if .Site.Params.moreMeta -}}
<span class="more-meta"> {{ printf $lang.posts.header.wordCount .WordCount }} </span>
<span class="more-meta"> {{ printf $lang.posts.header.readingTime .ReadingTime }} </span>
{{- end }}
</div> </div>
</header> </header>
<!-- Content --> <!-- Content -->

View file

@ -13,15 +13,15 @@
} }
.post-meta { .post-meta {
font-size: 14px;
color: $post-meta-font-color;
.post-time { .post-time {
font-size: 15px; font-size: 15px;
color: $post-time-font-color;
} }
.post-category { .post-category {
display: inline; display: inline;
font-size: 14px;
color: $post-category-font-color;
&::before { &::before {
content: '·'; content: '·';
@ -35,5 +35,12 @@
} }
} }
} }
.more-meta {
&::before {
content: '·';
}
}
} }
} }

View file

@ -128,11 +128,8 @@ $post-title-font-weight: 400 !default;
// Margin top of the post meta (post time). // Margin top of the post meta (post time).
$post-meta-margin-top: 5px !default; $post-meta-margin-top: 5px !default;
// Font color of the post time. // Font color of the post meta.
$post-time-font-color: $dark-gray !default; $post-meta-font-color: $dark-gray !default;
// Font color of the post category
$post-category-font-color: $dark-gray !default;
// Border bottom of the read more link when hover it. // Border bottom of the read more link when hover it.
$post-readMore-border-bottom: 1px solid $theme-color !default; $post-readMore-border-bottom: 1px solid $theme-color !default;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long