diff --git a/docs b/docs index 4120618e0..af9cedead 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 4120618e08e64716fd4c07e7cd2c41b976c2d5c8 +Subproject commit af9cedead5f7fe9c0fac1173221283e236790ee9 diff --git a/hugo.toml b/hugo.toml index 0cfacfe04..83cdd5e99 100644 --- a/hugo.toml +++ b/hugo.toml @@ -225,6 +225,14 @@ enableEmoji = true mediaType = "text/plain" isPlainText = true isHTML = false + # FixIt 0.3.0 | NEW Options to make output /archives/index.html file + [archives] + path = "archives" + baseName = "index" + mediaType = "text/html" + isPlainText = false + isHTML = true + permalinkable = true # ------------------------------------------------------------------------------------- # Customizing Output Formats @@ -232,7 +240,7 @@ enableEmoji = true # ------------------------------------------------------------------------------------- [outputs] - home = ["HTML", "RSS", "JSON", "BaiduUrls"] + home = ["HTML", "RSS", "JSON", "BaiduUrls", "archives"] page = ["HTML", "MarkDown"] section = ["HTML", "RSS"] taxonomy = ["HTML"] @@ -423,15 +431,23 @@ enableEmoji = true visitor = 0 beian = 0 - # Section (all posts) page config + # FixIt 0.3.0 | NEW Archives page config (all pages of posts type) + [params.archives] + # special amount of posts in archives page + paginate = 20 + # date format (month and day) + dateFormat = "01-02" + + # Section page config (all pages in section) [params.section] - # special amount of posts in each section page + # special amount of pages in each section page paginate = 20 # date format (month and day) dateFormat = "01-02" # amount of RSS pages rss = 10 - # FixIt 0.2.13 | NEW recently updated posts settings + # FixIt 0.2.13 | NEW recently updated pages config + # TODO refactor to support archives, section, taxonomy and term [params.section.recentlyUpdated] enable = false rss = false diff --git a/i18n/en.toml b/i18n/en.toml index 42736b951..ab799cdf9 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -18,6 +18,9 @@ noscript = "Theme FixIt works best with JavaScript enabled." # === baseof === # === Taxonomy === +[archives] +other = "Archives" + [allSome] other = "All {{ .Some }}" diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml index 65d70dbf3..3bcc2ce0d 100644 --- a/i18n/zh-CN.toml +++ b/i18n/zh-CN.toml @@ -19,6 +19,9 @@ noscript = "FixIt 主题在启用 JavaScript 的情况下效果最佳。" # === baseof === # === Taxonomy === +[archives] +other = "归档" + [allSome] other = "所有{{ .Some }}" diff --git a/i18n/zh-TW.toml b/i18n/zh-TW.toml index ce0c04068..7300e5bbe 100644 --- a/i18n/zh-TW.toml +++ b/i18n/zh-TW.toml @@ -19,6 +19,8 @@ noscript = "FixIt 主題在啟用 JavaScript 的情況下效果最佳。" # === baseof === # === Taxonomy === +[archives] +other = "歸檔" [allSome] other = "所有{{ .Some }}" diff --git a/layouts/_default/section.html b/layouts/_default/section.html index eab029ba0..7d3f7525b 100644 --- a/layouts/_default/section.html +++ b/layouts/_default/section.html @@ -8,8 +8,8 @@
{{- /* Title */ -}}

- {{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }} - {{- len .Pages -}} + {{- dict "Class" "fa-solid fa-feather fa-fw me-1" | partial "plugin/icon.html" -}} + {{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }} {{ .Pages.Len }}

{{- /* Total word count */ -}} {{- /* See https://github.com/hugo-fixit/FixIt/issues/124 */ -}} @@ -38,7 +38,10 @@

{{- end -}} {{- partial "recently-updated.html" . -}} {{- range $pages.PageGroups -}} -

{{ .Key }}

+

+ {{- dict "Class" "fa-regular fa-calendar fa-fw me-1" | partial "plugin/icon.html" -}} + {{- .Key -}} +

{{- range .Pages -}}
diff --git a/layouts/index.archives.html b/layouts/index.archives.html new file mode 100644 index 000000000..ca9097f4a --- /dev/null +++ b/layouts/index.archives.html @@ -0,0 +1,65 @@ +{{- define "title" -}} + {{- .Params.Title | default (T "archives") -}} + {{- if .Site.Params.withSiteTitle }} {{ .Site.Params.titleDelimiter }} {{ .Site.Title }}{{- end -}} +{{- end -}} + +{{- define "content" -}} + {{- /* All Posts */ -}} + {{- $pages := where .Site.RegularPages "Type" "posts" -}} + +
+
+ {{- /* Title */ -}} +

+ {{- dict "Class" "fa-solid fa-box-archive fa-fw me-1" | partial "plugin/icon.html" -}} + {{- .Params.Title | default (T "archives") }} {{ $pages.Len }} +

+ {{- /* Total word count */ -}} + {{- /* See https://github.com/hugo-fixit/FixIt/issues/124 */ -}} + {{- $localData := newScratch -}} + {{- range $pages -}} + {{- $localData.Add "totalWordCount" .WordCount -}} + {{- end -}} + {{- with ($localData.Get "totalWordCount") -}} + {{- $humanizedNum := . -}} + {{- if ge $humanizedNum 1000 -}} + {{- $humanizedNum = printf "%.2fK" (div $humanizedNum 1000.0) -}} + {{- end -}} +

+ {{- dict "Class" "fa-regular fa-keyboard fa-fw" | partial "plugin/icon.html" }} {{ T "section.totalWordCount" (dict "Count" $humanizedNum) -}} +

+ {{- end -}} +
+ + {{- /* Paginate */ -}} + {{- if $pages -}} + {{- $pages = $pages.GroupByDate "2006" -}} + {{- with .Site.Params.archives.paginate | default .Site.Params.paginate -}} + {{- $pages = $.Paginate $pages . -}} + {{- else -}} + {{- $pages = .Paginate $pages -}} + {{- end -}} + {{- range $pages.PageGroups -}} +

+ {{- dict "Class" "fa-regular fa-calendar fa-fw me-1" | partial "plugin/icon.html" -}} + {{- .Key -}} +

+ {{- range .Pages -}} +
+ {{- end -}} + {{- end -}} + {{- partial "paginator.html" . -}} + {{- end -}} +
+{{- end -}} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index b01c13d00..bfeddc7ba 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -33,7 +33,7 @@ {{- /* Author */ -}} {{- if ne .Site.Params.footer.author false -}} - {{ partial "plugin/link.html" (dict "Destination" ($.Site.Params.author.link | default .Site.Home.RelPermalink) "Content" .Site.Params.author.name) -}} + {{ partial "plugin/link.html" (dict "Destination" ($.Site.Params.author.link | default (.Scratch.Get "homeRelPermalink")) "Content" .Site.Params.author.name) -}} {{- end -}} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index ed5d7e29b..60f77a4c7 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,10 +1,11 @@ {{- $buildDrafts := .Site.BuildDrafts -}} +{{- $homeRelPermalink := .Scratch.Get "homeRelPermalink" -}} {{- /* Desktop header */ -}}
- + {{- with .Site.Params.header.title -}} {{- with .logo -}} {{- dict "Src" . "Class" "logo" "Alt" $.Site.Title | partial "plugin/image.html" -}} @@ -154,7 +155,7 @@
- + {{- with .Site.Params.header.title -}} {{- with .logo -}} {{- dict "Src" . "Class" "logo" | partial "plugin/image.html" -}} @@ -167,13 +168,13 @@ {{- dict $id (slice $id) | dict "typeitMap" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}} {{- else -}} - {{- .name -}} + {{ .name | default $.Site.Title }} {{- end -}} {{- with .post -}} {{ . | safeHTML }} {{- end -}} {{- else -}} - {{- .Site.Title -}} + {{ .Site.Title }} {{- end -}} {{- with .Site.Params.header.subtitle -}} diff --git a/layouts/partials/init/global.html b/layouts/partials/init/global.html index 0b0a57f0a..c587bb2ea 100644 --- a/layouts/partials/init/global.html +++ b/layouts/partials/init/global.html @@ -4,3 +4,8 @@ {{- $customFilePath = dict "profile" ($customFilePath.profile | default "custom/profile.html") | merge $customFilePath -}} {{- $customFilePath = dict "footer" ($customFilePath.footer | default "custom/footer.html") | merge $customFilePath -}} {{- .Scratch.Set "customFilePath" $customFilePath -}} + +{{- /* Set site home relative permalink */ -}} +{{- $homeRelPermalink := .Site.Home.RelPermalink -}} +{{- $homeRelPermalink = strings.TrimSuffix "archives/" $homeRelPermalink -}} +{{- .Scratch.Set "homeRelPermalink" $homeRelPermalink -}} diff --git a/layouts/partials/recently-updated.html b/layouts/partials/recently-updated.html index 03726eace..6d781f8fe 100644 --- a/layouts/partials/recently-updated.html +++ b/layouts/partials/recently-updated.html @@ -1,3 +1,5 @@ +{{- /* Recently updated pages */ -}} +{{- /* TODO refactor to support archives, section, taxonomy and term. */ -}} {{- if and .Site.Params.section.recentlyUpdated.enable (eq $.Paginator.PageNumber 1) -}} {{- $hasTitle := false }} {{- $postCount := 0 -}} @@ -8,7 +10,10 @@ {{- if ne .Lastmod.Unix .Date.Unix }} {{- $postCount = add $postCount 1 -}} {{- if eq $hasTitle false -}} -

{{- T "section.recentlyUpdated" -}}

+

+ {{- dict "Class" "fa-regular fa-calendar-check fa-fw me-1" | partial "plugin/icon.html" -}} + {{- T "section.recentlyUpdated" -}} +

{{- $hasTitle = true -}} {{- end -}}
diff --git a/layouts/posts/single.html b/layouts/posts/single.html index c84ae9957..d3c3d1c06 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -44,17 +44,18 @@

{{- partial "single/post-author.html" . -}} {{- partial "single/post-included-in.html" . -}}

+ {{- /* TODO add disclaimer or space between meta and content */ -}}