From 5f44f7a50db09547da7d06c3a8da464153d9cf20 Mon Sep 17 00:00:00 2001 From: amzrk2 Date: Thu, 7 May 2020 11:48:10 +0800 Subject: Word count and read time in post metadata --- assets/sass/modules/_archive.scss | 10 +++++++++- assets/sass/modules/_content.scss | 9 +++++++-- exampleSite/config.toml | 4 ++++ i18n/en.toml | 9 +++------ i18n/ja.toml | 11 ++++------- i18n/nl.toml | 9 +++------ i18n/zh-hans.toml | 9 +++------ i18n/zh-hant.toml | 9 +++------ layouts/partials/post-exlink.html | 1 - layouts/partials/post-meta.html | 10 +--------- 10 files changed, 37 insertions(+), 44 deletions(-) delete mode 100644 layouts/partials/post-exlink.html diff --git a/assets/sass/modules/_archive.scss b/assets/sass/modules/_archive.scss index 88b2993..8a9a92b 100644 --- a/assets/sass/modules/_archive.scss +++ b/assets/sass/modules/_archive.scss @@ -18,10 +18,18 @@ .post-meta-archive { color: $color-mute; - padding: 0; + padding: 0 0.1rem; white-space: nowrap; overflow-x: scroll; + time { + padding-right: 1rem; + } + + span:not(:last-child) { + display: none; + } + &::-webkit-scrollbar { display: none; // WebKit } diff --git a/assets/sass/modules/_content.scss b/assets/sass/modules/_content.scss index a88671c..54209da 100644 --- a/assets/sass/modules/_content.scss +++ b/assets/sass/modules/_content.scss @@ -26,10 +26,15 @@ article { .post-meta { color: $color-mute; - padding: 0.5rem 0 1rem 0; + padding: 0.5rem 0.1rem 1.25rem 0.1rem; white-space: nowrap; overflow-x: scroll; + time, + span:not(:last-child) { + padding-right: 1rem; + } + &::-webkit-scrollbar { display: none; // WebKit } @@ -52,7 +57,7 @@ article { #post-aplayer { font-family: inherit; - margin: 0 2px 1.5rem 2px; + margin: 0 0.1rem 1.5rem 0.1rem; } .license { diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 9238c31..3735d09 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -23,6 +23,10 @@ paginate = 10 author = "DSRKafuU" # You can also set author in post front matter individually subTitle = "This is a Sub Title" + # Word counter and read time indicator in post metadata + showWordCounter = true + showReadTime = true + # Open Graph & Twitter Card variables # You can also set description and images in post front matter individually description = "A minimal hugo theme powered by Primer CSS." diff --git a/i18n/en.toml b/i18n/en.toml index 02853ac..ef33505 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -25,6 +25,9 @@ [postMetaWordCount] other = " words" +[postMetaReadingTime] + other = " minutes" + [postCopyrightFront] other = "Unless otherwise noted, the content of this site is licensed under " @@ -42,9 +45,3 @@ [tagsCurrentTag] other = "Posts with the tag {{ .Title }}: " - -[webpCheckerFront] - other = "Your browser does not currently support " - -[webpCheckerEnd] - other = " images" diff --git a/i18n/ja.toml b/i18n/ja.toml index eb283e6..e5ff191 100644 --- a/i18n/ja.toml +++ b/i18n/ja.toml @@ -23,7 +23,10 @@ other = "タグはありません" [postMetaWordCount] - other = " 文字" + other = " 字" + +[postMetaReadingTime] + other = " 分" [postCopyrightFront] other = "特定のセクションを除いて、このサイトは " @@ -42,9 +45,3 @@ [tagsCurrentTag] other = "タグ {{ .Title }} を持つ記事:" - -[webpCheckerFront] - other = "お使いのブラウザは現在 " - -[webpCheckerEnd] - other = " 画像の表示に対応していません" diff --git a/i18n/nl.toml b/i18n/nl.toml index 7366e87..1d0b74a 100644 --- a/i18n/nl.toml +++ b/i18n/nl.toml @@ -25,6 +25,9 @@ [postMetaWordCount] other = " woorden" +[postMetaReadingTime] + other = " minuten" + [postCopyrightFront] other = "Tenzij anders vermeld is de inhoud van deze site eigendom van " @@ -42,9 +45,3 @@ [tagsCurrentTag] other = "Alle posts met de tag {{ .Title }}: " - -[webpCheckerFront] - other = "Uw huidige browser ondersteund deze pagina niet " - -[webpCheckerEnd] - other = " afbeeldingen" \ No newline at end of file diff --git a/i18n/zh-hans.toml b/i18n/zh-hans.toml index 56783e4..3be1131 100644 --- a/i18n/zh-hans.toml +++ b/i18n/zh-hans.toml @@ -25,6 +25,9 @@ [postMetaWordCount] other = " 字" +[postMetaReadingTime] + other = " 分钟" + [postCopyrightFront] other = "除特殊注明部分,本站内容采用 " @@ -42,9 +45,3 @@ [tagsCurrentTag] other = "拥有标签 {{ .Title }} 的文章:" - -[webpCheckerFront] - other = "您的浏览器暂未支持显示 " - -[webpCheckerEnd] - other = " 图片" diff --git a/i18n/zh-hant.toml b/i18n/zh-hant.toml index 1f2ba0a..a482017 100644 --- a/i18n/zh-hant.toml +++ b/i18n/zh-hant.toml @@ -25,6 +25,9 @@ [postMetaWordCount] other = " 字" +[postMetaReadingTime] + other = " 分鐘" + [postCopyrightFront] other = "除特殊註明部分,本站內容採用 " @@ -42,9 +45,3 @@ [tagsCurrentTag] other = "擁有標籤 {{ .Title }} 的文章:" - -[webpCheckerFront] - other = "您的瀏覽器暫未支持顯示 " - -[webpCheckerEnd] - other = " 圖片" diff --git a/layouts/partials/post-exlink.html b/layouts/partials/post-exlink.html deleted file mode 100644 index da81614..0000000 --- a/layouts/partials/post-exlink.html +++ /dev/null @@ -1 +0,0 @@ - READ MORE  \ No newline at end of file diff --git a/layouts/partials/post-meta.html b/layouts/partials/post-meta.html index f208210..2fd1091 100644 --- a/layouts/partials/post-meta.html +++ b/layouts/partials/post-meta.html @@ -1,9 +1 @@ - | -{{ .WordCount }}{{ i18n "postMetaWordCount" }} | -{{ if .Params.tags }} -{{ range .Params.tags }} -{{ . }} -{{ end }} -{{ else }} -{{ i18n "postMetaNoTag" }} -{{ end }} \ No newline at end of file +{{ if .Site.Params.showWordCounter }} {{ .WordCount }}{{ i18n "postMetaWordCount" }}{{ end }}{{ if .Site.Params.showReadTime }} {{ .ReadingTime }}{{ i18n "postMetaReadingTime" }}{{ end }}{{ if .Params.tags }} {{ range .Params.tags }}{{ . }} {{ end }}{{ else }}{{ i18n "postMetaNoTag" }}{{ end }} \ No newline at end of file -- cgit v1.2.3