From bb77f9bfb69e64fde85c25d48bfaeca563f5a495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=A1=E6=A2=A6=E6=98=9F=E5=B0=98?= Date: Wed, 1 Jun 2022 17:06:27 +0800 Subject: [PATCH] :building_construction: Finish the post meta attributes redesign. --- .../_common/components/post/post-header.scss | 2 +- assets/css/main.scss | 4 +-- exampleSite/config.yaml | 23 +++++++++------- exampleSite/content/post/hello-world.md | 13 +++++---- i18n/en-us.yaml | 8 +++--- i18n/zh-cn.yaml | 8 +++--- layouts/_default/baseof.html | 4 +-- layouts/index.html | 16 ++++++----- layouts/partials/post_meta/categories.html | 17 ++++++++++++ layouts/partials/post_meta/created_date.html | 12 +++++++++ layouts/partials/post_meta/readtime.html | 9 +++++++ layouts/partials/post_meta/update_date.html | 12 +++++++++ layouts/partials/post_meta/views.html | 27 +++++++++++++++++++ layouts/partials/post_meta/words.html | 9 +++++++ 14 files changed, 129 insertions(+), 35 deletions(-) create mode 100644 layouts/partials/post_meta/categories.html create mode 100644 layouts/partials/post_meta/created_date.html create mode 100644 layouts/partials/post_meta/readtime.html create mode 100644 layouts/partials/post_meta/update_date.html create mode 100644 layouts/partials/post_meta/views.html create mode 100644 layouts/partials/post_meta/words.html diff --git a/assets/css/_common/components/post/post-header.scss b/assets/css/_common/components/post/post-header.scss index 3c7eb44..25f9cab 100644 --- a/assets/css/_common/components/post/post-header.scss +++ b/assets/css/_common/components/post/post-header.scss @@ -1,6 +1,6 @@ .posts-expand .post-header { font-size: $font-size-large; - margin-bottom: 60px; + margin-bottom: 40px; text-align: center; } diff --git a/assets/css/main.scss b/assets/css/main.scss index 48a98ad..993a7c9 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -80,8 +80,8 @@ $post_meta_item_text: {{ $P.postMeta.itemText }}; $reward_settings_animation: {{ $P.rewardSets.animation }}; // TODO find the paramters -$text_align_desktop: center; -$text_align_mobile: center; +$text_align_desktop: justify; +$text_align_mobile: justify; // Note $note_icons: {{ $P.note.icons }}; diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 2073a3a..ddc40d6 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -8,8 +8,6 @@ baseURL: / theme: hugo-theme-next -mainSections: ["post"] - defaultContentLanguage: zh-cn languages: zh-cn: @@ -55,6 +53,9 @@ menus: weight: 4 params: + mainSections: ["post"] + dateFormat: "2006-01-02" + timeFormat: "2006-01-02T15:04:05-07:00" # --------------------------------------------------------------- # Theme Core Configuration Settings # See: https://theme-next.js.org/docs/theme-settings/ @@ -317,12 +318,14 @@ params: enable: true anotherDay: true categories: true + wordCount: true + readTime: true # Post wordcount display settings # Dependencies: https://github.com/next-theme/hexo-word-counter - symbols_count_time: - separated_meta: true - item_text_total: false + # symbols_count_time: + # separated_meta: true + # item_text_total: false # Use icon instead of the symbol # to indicate the tag at the bottom of the post tag_icon: false @@ -759,12 +762,12 @@ params: # Show number of visitors of each article. # You can visit https://www.leancloud.cn to get AppID and AppKey. - leancloud_visitors: + leancloudVisitors: enable: false - app_id: # - app_key: # + appId: # + appKey: # # Required for apps from CN region - server_url: # + serverUrl: # # Dependencies: https://github.com/theme-next/hexo-leancloud-counter-security # If you don't care about security in leancloud counter and just want to use it directly # (without hexo-leancloud-counter-security plugin), set `security` to `false`. @@ -787,7 +790,7 @@ params: visitorsIcon: fa fa-user views: true viewsIcon: fa fa-eye - postViews: false + postViews: true postViewsIcon: far fa-eye diff --git a/exampleSite/content/post/hello-world.md b/exampleSite/content/post/hello-world.md index 6597354..7645001 100644 --- a/exampleSite/content/post/hello-world.md +++ b/exampleSite/content/post/hello-world.md @@ -1,12 +1,12 @@ --- -title: 'Hugo blog Hello World' +title: Hello World description: 'Short description of the article.' keywords: 'Key words' -isCJKLanguage: true +isCJKLanguage: false author: 'Author of the article' lastmod: '2022-05-21T17:06:24+08:00' -publishDate: '2022-05-21T17:06:24+08:00' +publishDate: '2022-05-21T16:06:24+08:00' weight: 1 categories: @@ -16,12 +16,15 @@ tags: - Startup toc: false -draft: true -url: 'hello_world.html' +draft: false --- +The world’s fastest framework for building websites. + [Hugo](https://gohugo.io/) is one of the most popular open-source static site generators. With its amazing speed and flexibility, Hugo makes building websites fun again. + + ## Quick Start ### Create a new post diff --git a/i18n/en-us.yaml b/i18n/en-us.yaml index f620c28..5050f74 100644 --- a/i18n/en-us.yaml +++ b/i18n/en-us.yaml @@ -8,7 +8,7 @@ NavToggleLabel: MSearchLabel: other: Search -ColoneFlag: +SymbolColon: other: ":" SitePostsTitle: @@ -19,8 +19,8 @@ SiteTagsTitle: other: "Tags" TableOfContents: other: "TOC" -SiteInfo: - other: "Site Info" +SiteOverview: + other: "Overview" RSSTitle: other: "RSS Subscribe" CCLinkTitle: @@ -44,7 +44,7 @@ PostReading: other: "Read" PostReadTime: other: "{{- .ReadingTime -}}min" -PostVisitor: +PostViews: other: "Views" PostCatg: other: "Categories" diff --git a/i18n/zh-cn.yaml b/i18n/zh-cn.yaml index c0e501d..2936ff8 100644 --- a/i18n/zh-cn.yaml +++ b/i18n/zh-cn.yaml @@ -8,7 +8,7 @@ NavToggleLabel: MSearchLabel: other: 搜索 -ColoneFlag: +SymbolColon: other: ":" SbPostsLable: @@ -46,11 +46,11 @@ PostReading: other: 阅读 PostReadTime: other: "{{- .ReadingTime -}}分钟" -PostVisitor: +PostViews: other: 浏览数 -PostCatg: +PostCatgs: other: 分类 -PostTag: +PostTags: other: 标签 PostReadMore: other: 阅读全文 diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index bbf8305..b2c0679 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -40,9 +40,9 @@ {{ partial "widgets.html" . }} -
+
- {{- block "main" (dict "P" $P "Page" .Page "Paginate" (.Paginate (where .Site.RegularPages "Section" "in" .Site.Params.mainSections)) "Scratch" .Scratch) }}{{- end }} + {{- block "main" . }}{{- end }}
diff --git a/layouts/index.html b/layouts/index.html index 9ef13ac..bece7f1 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,14 +1,13 @@ {{- define "main" }} -{{ $P := .P }} {{- $lang := .Scratch.Get "lang" }} -{{/* $paginator := .Paginate (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections) */}} -{{- range .Paginate.Pages }} +{{ $paginator := .Paginate (where .Site.RegularPages "Section" "in" .Site.Params.mainSections) }} +{{- range $paginator.Pages }}
- - + + @@ -34,7 +33,10 @@ {{/*- end */}}
- {{/* partial "post/meta" . */}} + {{ partial "post_meta/created_date.html" . }} + {{ partial "post_meta/update_date.html" . }} + {{ partial "post_meta/categories.html" . }} + {{ partial "post_meta/words.html" . }}
@@ -46,7 +48,7 @@ {{/*- end */}}
- {{- if and $P.readMoreBtn }} + {{- if and .Site.Params.readMoreBtn }}
{{ T "PostReadMore" }} » diff --git a/layouts/partials/post_meta/categories.html b/layouts/partials/post_meta/categories.html new file mode 100644 index 0000000..46e17bd --- /dev/null +++ b/layouts/partials/post_meta/categories.html @@ -0,0 +1,17 @@ +{{- if .Site.Params.postMeta.categories }} +{{- if gt (len .Params.categories) 0 }} + + + + + {{ print (T "PostCatgs") (T "SymbolColon") }} + {{- range (first 3 .Params.categories) }} + + + {{ . }} + + + {{- end }} + +{{- end }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/post_meta/created_date.html b/layouts/partials/post_meta/created_date.html new file mode 100644 index 0000000..fe37504 --- /dev/null +++ b/layouts/partials/post_meta/created_date.html @@ -0,0 +1,12 @@ +{{- if .Site.Params.postMeta.created }} +{{ $createdTime := .PublishDate.Format .Site.Params.timeFormat }} + + + + + {{ print (T "PostPublishDate") (T "SymbolColon") }} + + {{- .PublishDate.Format .Site.Params.dateFormat -}} + + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/post_meta/readtime.html b/layouts/partials/post_meta/readtime.html new file mode 100644 index 0000000..d3a3c6c --- /dev/null +++ b/layouts/partials/post_meta/readtime.html @@ -0,0 +1,9 @@ +{{- if .Site.Params.postMeta.readTime }} + + + + + {{ print (T "PostReading") (T "SymbolColon") }} ≈ + {{- T "PostReadTime" . -}} + +{{- end }} diff --git a/layouts/partials/post_meta/update_date.html b/layouts/partials/post_meta/update_date.html new file mode 100644 index 0000000..8f98b14 --- /dev/null +++ b/layouts/partials/post_meta/update_date.html @@ -0,0 +1,12 @@ +{{- if and .Site.Params.postMeta.updated.enable .Site.Params.postMeta.updated.anotherDay }} +{{- if gt .Lastmod .PublishDate }} +{{ $modTime := .Lastmod.Format .Site.Params.timeFormat }} + + + + + {{ print (T "PostLastModDate") (T "SymbolColon") }} + {{ .Lastmod.Format .Site.Params.dateFormat }} + +{{- end }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/post_meta/views.html b/layouts/partials/post_meta/views.html new file mode 100644 index 0000000..a7b7379 --- /dev/null +++ b/layouts/partials/post_meta/views.html @@ -0,0 +1,27 @@ +{{- if .Site.Params.leancloudVisitors.enable }} + + + + + {{ print (T "PostViews") (T "SymbolColon") }} + + +{{- end }} +{{- if .Site.Params.firestore.enable }} + + + + + {{ print (T "PostViews") (T "SymbolColon") }} + + +{{- end }} +{{- if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.postViews }} + + + + + {{ print (T "PostViews") (T "SymbolColon") }} + + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/post_meta/words.html b/layouts/partials/post_meta/words.html new file mode 100644 index 0000000..ee9c9b1 --- /dev/null +++ b/layouts/partials/post_meta/words.html @@ -0,0 +1,9 @@ +{{- if .Site.Params.postMeta.wordCount }} + + + + + {{ print (T "PostWords") (T "SymbolColon") }} + {{ T "PostWordCount" . }} + +{{- end }} \ No newline at end of file