mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-09-02 19:52:40 +00:00
✨ Feat: add archives page template (#397)
* ✨ Feat: add archives page template * 🎨 Style: add some icon for theme built-in templates * 🔧 Chore: set site home relative permalink globally * 🔧 Chore: add archives outputs config
This commit is contained in:
+1
-1
Submodule docs updated: 4120618e08...af9cedead5
@@ -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
|
||||
|
||||
@@ -18,6 +18,9 @@ noscript = "Theme FixIt works best with JavaScript enabled."
|
||||
# === baseof ===
|
||||
|
||||
# === Taxonomy ===
|
||||
[archives]
|
||||
other = "Archives"
|
||||
|
||||
[allSome]
|
||||
other = "All {{ .Some }}"
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ noscript = "FixIt 主题在启用 JavaScript 的情况下效果最佳。"
|
||||
# === baseof ===
|
||||
|
||||
# === Taxonomy ===
|
||||
[archives]
|
||||
other = "归档"
|
||||
|
||||
[allSome]
|
||||
other = "所有{{ .Some }}"
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ noscript = "FixIt 主題在啟用 JavaScript 的情況下效果最佳。"
|
||||
# === baseof ===
|
||||
|
||||
# === Taxonomy ===
|
||||
[archives]
|
||||
other = "歸檔"
|
||||
[allSome]
|
||||
other = "所有{{ .Some }}"
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
<div class="header">
|
||||
{{- /* Title */ -}}
|
||||
<h1 class="single-title animate__animated animate__pulse animate__faster">
|
||||
{{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "allSome" }}
|
||||
<sup>{{- len .Pages -}}</sup>
|
||||
{{- 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" }} <sup>{{ .Pages.Len }}</sup>
|
||||
</h1>
|
||||
{{- /* Total word count */ -}}
|
||||
{{- /* See https://github.com/hugo-fixit/FixIt/issues/124 */ -}}
|
||||
@@ -38,7 +38,10 @@
|
||||
{{- end -}}
|
||||
{{- partial "recently-updated.html" . -}}
|
||||
{{- range $pages.PageGroups -}}
|
||||
<h2 class="group-title">{{ .Key }}</h2>
|
||||
<h2 class="group-title">
|
||||
{{- dict "Class" "fa-regular fa-calendar fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- .Key -}}
|
||||
</h2>
|
||||
{{- range .Pages -}}
|
||||
<article class="archive-item">
|
||||
<a href="{{ .RelPermalink }}" class="archive-item-link">
|
||||
|
||||
@@ -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" -}}
|
||||
|
||||
<div class="page archive">
|
||||
<div class="header">
|
||||
{{- /* Title */ -}}
|
||||
<h1 class="single-title animate__animated animate__pulse animate__faster">
|
||||
{{- dict "Class" "fa-solid fa-box-archive fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- .Params.Title | default (T "archives") }} <sup>{{ $pages.Len }}</sup>
|
||||
</h1>
|
||||
{{- /* 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 -}}
|
||||
<p class="single-subtitle total-word-count" title='{{- T "section.totalWordCount" . }}'>
|
||||
{{- dict "Class" "fa-regular fa-keyboard fa-fw" | partial "plugin/icon.html" }} {{ T "section.totalWordCount" (dict "Count" $humanizedNum) -}}
|
||||
</p>
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
{{- /* 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 -}}
|
||||
<h2 class="group-title">
|
||||
{{- dict "Class" "fa-regular fa-calendar fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- .Key -}}
|
||||
</h2>
|
||||
{{- range .Pages -}}
|
||||
<article class="archive-item">
|
||||
<a href="{{ .RelPermalink }}" class="archive-item-link">
|
||||
{{- $repost := .Params.repost | default dict -}}
|
||||
{{- if eq $repost.enable true -}}
|
||||
{{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}}
|
||||
{{- end -}}
|
||||
{{- .LinkTitle -}}
|
||||
</a>
|
||||
<span class="archive-item-date" title='{{ "2006-01-02 15:04:05" | .Date.Format }}'>
|
||||
{{- .Date | dateFormat ($.Site.Params.archives.dateFormat | default "01-02") -}}
|
||||
</span>
|
||||
</article>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- partial "paginator.html" . -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
@@ -33,7 +33,7 @@
|
||||
{{- /* Author */ -}}
|
||||
{{- if ne .Site.Params.footer.author false -}}
|
||||
<span class="author" itemprop="copyrightHolder">
|
||||
{{ 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) -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
{{- $buildDrafts := .Site.BuildDrafts -}}
|
||||
{{- $homeRelPermalink := .Scratch.Get "homeRelPermalink" -}}
|
||||
|
||||
{{- /* Desktop header */ -}}
|
||||
<header class="desktop animate__faster" id="header-desktop">
|
||||
<div class="header-wrapper"{{ if .Site.Params.githubCorner.enable }} data-github-corner="{{ .Site.Params.githubCorner.position }}"{{ end }}>
|
||||
<div class="header-title">
|
||||
<a href="{{ .Site.Home.RelPermalink }}" title="{{ .Site.Title }}">
|
||||
<a href="{{ $homeRelPermalink }}" title="{{ .Site.Title }}">
|
||||
{{- with .Site.Params.header.title -}}
|
||||
{{- with .logo -}}
|
||||
{{- dict "Src" . "Class" "logo" "Alt" $.Site.Title | partial "plugin/image.html" -}}
|
||||
@@ -154,7 +155,7 @@
|
||||
<div class="header-container">
|
||||
<div class="header-wrapper">
|
||||
<div class="header-title">
|
||||
<a href="{{ .Site.Home.RelPermalink }}" title="{{ .Site.Title }}">
|
||||
<a href="{{ $homeRelPermalink }}" title="{{ .Site.Title }}">
|
||||
{{- with .Site.Params.header.title -}}
|
||||
{{- with .logo -}}
|
||||
{{- dict "Src" . "Class" "logo" | partial "plugin/image.html" -}}
|
||||
@@ -167,13 +168,13 @@
|
||||
<span id="{{ $id }}" class="typeit"></span>
|
||||
{{- dict $id (slice $id) | dict "typeitMap" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}}
|
||||
{{- else -}}
|
||||
<span class="header-title-text">{{- .name -}}</span>
|
||||
<span class="header-title-text">{{ .name | default $.Site.Title }}</span>
|
||||
{{- end -}}
|
||||
{{- with .post -}}
|
||||
<span class="header-title-post">{{ . | safeHTML }}</span>
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
<span class="header-title-text">{{- .Site.Title -}}</span>
|
||||
<span class="header-title-text">{{ .Site.Title }}</span>
|
||||
{{- end -}}
|
||||
</a>
|
||||
{{- with .Site.Params.header.subtitle -}}
|
||||
|
||||
@@ -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 -}}
|
||||
|
||||
@@ -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 -}}
|
||||
<h2 class="group-title">{{- T "section.recentlyUpdated" -}}</h2>
|
||||
<h2 class="group-title">
|
||||
{{- dict "Class" "fa-regular fa-calendar-check fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- T "section.recentlyUpdated" -}}
|
||||
</h2>
|
||||
{{- $hasTitle = true -}}
|
||||
{{- end -}}
|
||||
<article class="archive-item">
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
{{- end -}}
|
||||
</section>
|
||||
<section>
|
||||
<span><a href="javascript:void(0);" onclick="window.history.back();">{{ T "single.back" }}</a></span> | <span><a href="{{ .Site.Home.RelPermalink }}">{{ T "single.home" }}</a></span>
|
||||
<span><a href="javascript:void(0);" onclick="window.history.back();">{{ T "single.back" }}</a></span> | <span><a href="{{ .Scratch.Get "homeRelPermalink" }}">{{ T "single.home" }}</a></span>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -44,17 +44,18 @@
|
||||
{{- partial "single/post-author.html" . -}}
|
||||
{{- partial "single/post-included-in.html" . -}}
|
||||
</div>
|
||||
{{- /* TODO add disclaimer or space between meta and content */ -}}
|
||||
<div class="post-meta-line">
|
||||
{{- with .PublishDate | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
|
||||
<span title="{{ dict "Date" ("2006-01-02 15:04:05" | $.PublishDate.Format) | T "single.publishedOnDate" }}">
|
||||
{{- dict "Class" "fa-regular fa-calendar-alt fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- dict "Class" "fa-solid fa-calendar-days fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- printf `<time datetime="%v">%v</time>` . . | safeHTML -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
{{- if ne .Lastmod.Unix .PublishDate.Unix }}
|
||||
{{- with .Lastmod | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
|
||||
<span title="{{ dict "Date" ("2006-01-02 15:04:05" | $.Lastmod.Format) | T "single.updatedOnDate" }}">
|
||||
{{- dict "Class" "fa-regular fa-edit fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- dict "Class" "fa-regular fa-calendar-check fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- printf `<time datetime="%v">%v</time>` . . | safeHTML -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
|
||||
@@ -11,19 +11,19 @@
|
||||
{{- $termIcon := "" -}}
|
||||
{{- $termTitle := .Title -}}
|
||||
{{- if eq $taxonomy "category" -}}
|
||||
{{- $termIcon = "fa-regular fa-folder-open fa-fw" -}}
|
||||
{{- $termIcon = "fa-regular fa-folder-open" -}}
|
||||
{{- else if eq $taxonomy "tag" -}}
|
||||
{{- $termIcon = "fa-solid fa-tag fa-fw" -}}
|
||||
{{- $termIcon = "fa-solid fa-tag" -}}
|
||||
{{- else if eq $taxonomy "collection" -}}
|
||||
{{- $termIcon = "fa-solid fa-layer-group fa-fw" -}}
|
||||
{{- $termIcon = "fa-solid fa-layer-group" -}}
|
||||
{{- else -}}
|
||||
{{- $termTitle = printf "%v - %v" (T $taxonomy | default $taxonomy) .Title -}}
|
||||
{{- end -}}
|
||||
<h2 class="single-title animate__animated animate__pulse animate__faster">
|
||||
{{- with $termIcon -}}
|
||||
{{- dict "Class" . | partial "plugin/icon.html" }}
|
||||
{{ end -}}
|
||||
{{ $termTitle }} <sup>{{- $pageCount -}}</sup>
|
||||
{{- dict "Class" (add . " fa-fw me-1") | partial "plugin/icon.html" -}}
|
||||
{{- end -}}
|
||||
{{- $termTitle }} <sup>{{ $pageCount }}</sup>
|
||||
</h2>
|
||||
|
||||
{{- /* Paginate */ -}}
|
||||
|
||||
@@ -7,10 +7,20 @@
|
||||
{{- $taxonomies := .Data.Plural -}}
|
||||
|
||||
<div class="page archive">
|
||||
{{- $termsIcon := "" -}}
|
||||
{{- if eq $taxonomies "categories" -}}
|
||||
{{- $termsIcon = "fa-solid fa-folder-tree" -}}
|
||||
{{- else if eq $taxonomies "tags" -}}
|
||||
{{- $termsIcon = "fa-solid fa-tags" -}}
|
||||
{{- else if eq $taxonomies "collections" -}}
|
||||
{{- $termsIcon = "fa-solid fa-layer-group" -}}
|
||||
{{- end -}}
|
||||
{{- /* Title */ -}}
|
||||
<h2 class="single-title animate__animated animate__pulse animate__faster">
|
||||
{{- .Params.Title | default (T $taxonomies) | default $taxonomies | dict "Some" | T "allSome" }}
|
||||
<sup>{{- len .Data.Terms.ByCount -}}</sup>
|
||||
{{- with $termsIcon -}}
|
||||
{{- dict "Class" (add . " fa-fw me-1") | partial "plugin/icon.html" -}}
|
||||
{{- end -}}
|
||||
{{- .Params.Title | default (T $taxonomies) | default $taxonomies | dict "Some" | T "allSome" }} <sup>{{ len .Data.Terms.ByCount }}</sup>
|
||||
</h2>
|
||||
{{- /* Render miscellaneous terms */ -}}
|
||||
{{- .Render (add "terms/" $taxonomies) -}}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<div class="card-item-wrapper">
|
||||
<h3 class="card-item-title">
|
||||
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}'>
|
||||
{{ dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html" }}
|
||||
{{ .Page.Title }} <sup>{{- len $pages -}}</sup>
|
||||
{{- dict "Class" "fa-regular fa-folder fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- .Page.Title }} <sup>{{ len $pages }}</sup>
|
||||
</a>
|
||||
</h3>
|
||||
{{- range first 5 $pages -}}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<div class="card-item-wrapper">
|
||||
<h3 class="card-item-title">
|
||||
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}'>
|
||||
{{ dict "Class" "fa-solid fa-layer-group fa-fw" | partial "plugin/icon.html" }}
|
||||
{{ .Page.Title }} <sup>{{- len $pages -}}</sup>
|
||||
{{- dict "Class" "fa-solid fa-layer-group fa-fw me-1" | partial "plugin/icon.html" -}}
|
||||
{{- .Page.Title }} <sup>{{ len $pages }}</sup>
|
||||
</a>
|
||||
</h3>
|
||||
{{- range first 5 $pages -}}
|
||||
|
||||
Reference in New Issue
Block a user