From 52c7ad29a60cc4ee6c51217d11bb4877ef0cf88a Mon Sep 17 00:00:00 2001 From: Dillon Date: Mon, 3 Feb 2020 18:38:10 +0800 Subject: [PATCH] chore(style): update code style and add an i18n word --- exampleSite/config.toml | 8 ++ exampleSite/zh/config.toml | 8 ++ i18n/en.toml | 5 + i18n/zh.toml | 5 + layouts/404.html | 8 +- layouts/_default/_markup/render-image.html | 14 +-- layouts/_default/baseof.html | 11 +- layouts/_default/section.html | 3 +- layouts/_default/single.html | 3 + layouts/_default/summary.html | 22 ++-- layouts/index.html | 7 +- layouts/partials/comments.html | 76 +++++++----- layouts/partials/footer.html | 17 ++- layouts/partials/head.html | 5 +- layouts/partials/header.html | 8 +- layouts/partials/hook/content.html | 1 + layouts/partials/image.html | 1 + layouts/partials/post/share.html | 61 ++++++---- layouts/partials/scripts.html | 129 +++++++++++---------- layouts/partials/seo.html | 5 +- layouts/posts/single.html | 20 ++-- layouts/taxonomy/list.html | 2 + layouts/taxonomy/terms.html | 6 +- 23 files changed, 270 insertions(+), 155 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 9fb59689..aee4015c 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -38,6 +38,14 @@ dateFormatToUse = "2006-01-02" tabWidth = 4 # Goldmark is from Hugo 0.60 the default library used for Markdown [markup.goldmark] + [markup.goldmark.extensions] + definitionList = true + footnote = true + linkify = true + strikethrough = true + table = true + taskList = true + typographer = true [markup.goldmark.renderer] # whether to use HTML tags directly in the document unsafe = true diff --git a/exampleSite/zh/config.toml b/exampleSite/zh/config.toml index d6283c4b..a9b35d86 100644 --- a/exampleSite/zh/config.toml +++ b/exampleSite/zh/config.toml @@ -38,6 +38,14 @@ dateFormatToUse = "2006-01-02" tabWidth = 4 # Goldmark 是 Hugo 0.60 以来的默认 Markdown 解析库 [markup.goldmark] + [markup.goldmark.extensions] + definitionList = true + footnote = true + linkify = true + strikethrough = true + table = true + taskList = true + typographer = true [markup.goldmark.renderer] # 是否在文档中直接使用 HTML 标签 unsafe = true diff --git a/i18n/en.toml b/i18n/en.toml index 113b5ad9..6d957055 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -46,6 +46,11 @@ other = "Powered by %s" other = "Theme - " # === partials/footer.html === +# === partials/post/share.html === +[share] +other = "Share on" +# === partials/post/share.html === + # === posts/single.html === [toc] other = "Contents" diff --git a/i18n/zh.toml b/i18n/zh.toml index d4d54097..6b2db781 100644 --- a/i18n/zh.toml +++ b/i18n/zh.toml @@ -46,6 +46,11 @@ other = "由 %s 强力驱动" other = "主题 - " # === partials/footer.html === +# === partials/post/share.html === +[share] +other = "分享到" +# === partials/post/share.html === + # === posts/single.html === [toc] other = "目录" diff --git a/layouts/404.html b/layouts/404.html index 23a7ef8c..ed901efb 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -4,19 +4,19 @@ {{- define "content" -}}
-

+

{{- T "pageNotFoundText" -}}  ↩︎

{{- end -}} \ No newline at end of file diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index c143d1d6..402f4fef 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,11 +1,11 @@
+ {{- /* Lazyload */ -}} {{- $loading := resources.Get "svg/loading.svg" | minify -}} {{ .Text }} -
- {{- if .Title -}} - {{- .Title -}} - {{- else -}} - {{- .Text -}} - {{- end -}} -
+ {{- $caption := .Title | default .Text -}} + {{- with $caption -}} +
+ {{- . -}} +
+ {{- end -}}
\ No newline at end of file diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index a174f960..249ab81e 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,6 +1,8 @@ +{{- /* LoveIt theme version detection */ -}} {{- if ne .Site.Params.version "0.1.X" -}} {{- errorf "\n\nThere are two possible situations that led to this error:\n 1. You haven't copied the config.toml yet. See https://github.com/dillonzq/LoveIt#installation \n 2. You have an incompatible update. See https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n\n有两种可能的情况会导致这个错误发生:\n 1. 你还没有复制 config.toml 参考 https://github.com/dillonzq/LoveIt#installation \n 2. 你进行了一次不兼容的更新 参考 https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n" -}} {{- end -}} + @@ -12,10 +14,13 @@ {{- partial "head.html" . -}} + {{- /* Check theme isDark before body rendering */ -}} + + {{- /* Body wrapper */ -}}
{{- partial "header.html" . -}}
@@ -24,10 +29,14 @@
{{- partial "footer.html" . -}} - {{- partial "scripts.html" . -}} + + {{- /* Dynamic to top button */ -}}   + + {{- /* Load scripts */ -}} + {{- partial "scripts.html" . -}} \ No newline at end of file diff --git a/layouts/_default/section.html b/layouts/_default/section.html index a6f7aacb..499fd23a 100644 --- a/layouts/_default/section.html +++ b/layouts/_default/section.html @@ -3,12 +3,13 @@ {{- end -}} {{- define "content" -}} - {{- $data := .Data -}}
+ {{- /* Title */ -}}

{{- T "all" | humanize}}{{ T .Section | default .Section | humanize -}}

+ {{- /* Paginate */ -}} {{- range (.Paginate (.Pages.GroupByDate "2006")).PageGroups -}}

{{ .Key }}

{{- range .Pages -}} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 314e4db7..51d61ecb 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -2,9 +2,12 @@ {{- define "content" -}}
+ {{- /* Title */ -}}

{{- .Title -}}

+ + {{- /* Content */ -}}
{{- partial "hook/content.html" .Content | safeHTML -}}
diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index 0f1d4bbd..e7beb20a 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -1,26 +1,28 @@
- {{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}} - {{- $author := .Params.author | default .Site.Author.name -}} - {{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}} - - + {{- /* Featured image */ -}} {{- with .Params.featured_image -}}
{{- $image := $.Params.featured_image_preview | default . -}} {{- partial "image" $image -}}
{{- end -}} - + {{- /* Title */ -}}

{{ .Title }}

+ {{- /* Meta */ -}} + + {{- /* Content */ -}}
{{- if .Params.show_description -}}

@@ -43,6 +47,8 @@ {{- partial "hook/content.html" .Summary | safeHTML -}} {{- end -}}

+ + {{- /* Footer */ -}}