diff options
| author | BigCoke233 <hi@guhub.cn> | 2025-12-06 15:34:00 +0800 |
|---|---|---|
| committer | BigCoke233 <hi@guhub.cn> | 2025-12-06 15:34:00 +0800 |
| commit | 7089e990120da4acbe3e03c59856d5eb58380d5b (patch) | |
| tree | 8f434bf360113b825f257b28c88fc09504f37e0d | |
| parent | f4bbd561af49c7d3a55df1becc75cc8a0f06d822 (diff) | |
refactor: add book `author` as a taxonomy
Former-commit-id: 62e742330aedc52b47a9aa8a843a87122f43eaa6
| -rw-r--r-- | config/_default/config.yaml | 4 | ||||
| -rw-r--r-- | layouts/_partials/head/siteinfo.html | 12 | ||||
| -rw-r--r-- | layouts/library/page.html | 24 |
3 files changed, 24 insertions, 16 deletions
diff --git a/config/_default/config.yaml b/config/_default/config.yaml index 2ddc72a9..d52641bf 100644 --- a/config/_default/config.yaml +++ b/config/_default/config.yaml @@ -15,3 +15,7 @@ outputFormats: baseName: cal-heatmap isPlainText: true permalinkable: true +taxonomies: + author: authors + category: categories + tag: tags diff --git a/layouts/_partials/head/siteinfo.html b/layouts/_partials/head/siteinfo.html index 99f77b0f..129e1e6a 100644 --- a/layouts/_partials/head/siteinfo.html +++ b/layouts/_partials/head/siteinfo.html @@ -7,7 +7,7 @@ <title>{{ $title }}</title> <link rel="canonical" href="{{ .Permalink }}" /> -<meta name="author" content="{{ .Params.author | default .Site.Params.author }}" /> +<meta name="author" content="{{ .Site.Params.author }}" /> <link rel="icon" href="/favicon.ico"> <meta property="og:url" content="{{ .Permalink }}" /> <meta property="og:title" content="{{ $title }}" /> @@ -40,11 +40,11 @@ "description" : "{{ default .Summary .Description | plainify }}", {{- end }} "inLanguage" : "zh-CN", - "author" : "{{ .Params.author | default .Site.Params.author }}", - "creator" : "{{ .Params.author | default .Site.Params.author }}", - "publisher": "{{ .Params.author | default .Site.Params.author }}", - "accountablePerson" : "{{ .Params.author | default .Site.Params.author }}", - "copyrightHolder" : "{{ .Params.author | default .Site.Params.author }}", + "author" : "{{ .Site.Params.author }}", + "creator" : "{{ .Site.Params.author }}", + "publisher": "{{ .Site.Params.author }}", + "accountablePerson" : "{{ .Site.Params.author }}", + "copyrightHolder" : "{{ .Site.Params.author }}", "copyrightYear" : "{{ .Date.Format "2006" }}", "datePublished": "{{ .Date }}", "dateModified" : "{{ .Date }}", diff --git a/layouts/library/page.html b/layouts/library/page.html index df2192de..ffa4ca05 100644 --- a/layouts/library/page.html +++ b/layouts/library/page.html @@ -18,7 +18,7 @@ {{- $rating := .Params.rating -}} {{- $fullStars := math.Floor $rating -}} <p class="m-0"> - {{ .Params.author }} + {{ with .Params.authors }}{{ delimit . ", " }}{{ end }} </p> <p class="m-0"> {{- range seq $fullStars }} @@ -42,19 +42,23 @@ {{ partial "posts/action-menu.html" . }} {{ partial "components/back-to-top.html" . }} - {{ $books := where (where .Site.RegularPages "Section" "library") ".Params.author" "==" .Params.author }} - {{ $thisBookID := .File.UniqueID }} - {{ if gt (len $books) 1 }} - <h2>我读过的{{ .Params.author }}的其它书籍</h2> + + + {{ with .Params.authors }} + {{ $author := index . 0 }} + {{ $term := index $.Site.Taxonomies.authors $author }} + {{ if and $term (gt (len $term.Pages) 1) }} + <h2>我读过的 {{ $author }} 的其它书籍</h2> <div class="grid grid-cols-4 md:grid-cols-6 items-center gap-4 my-4"> - {{ range $books }} - {{ if ne .File.UniqueID $thisBookID }} - <div data-tooltip="{{ .Title }}"> + {{ range $term.Pages }} + {{ if ne .File.UniqueID $.File.UniqueID }} + <div data-tooltip="{{ .Title }}"> {{ partial "items/book" (dict "ctx" .) }} - </div> + </div> {{ end }} - {{ end }} + {{ end }} </div> + {{ end }} {{ end }} </article> {{ end }} |
