-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ 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
- Loading branch information
Showing
17 changed files
with
143 additions
and
29 deletions.
There are no files selected for viewing
Submodule docs
updated
4 files
+12 −2 | config/_default/outputFormats.toml | |
+1 −1 | config/_default/outputs.toml | |
+11 −4 | content/en/documentation/basics/index.md | |
+11 −4 | content/zh-cn/documentation/basics/index.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters