From 8f0a341644fb0d9575b5429ca6193609a4d12d02 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Wed, 21 Jan 2026 17:34:37 -0500 Subject: tags --- layouts/_partials/articles/header.html | 8 -------- layouts/_partials/asset-table.html | 2 +- layouts/_partials/assets.html | 2 +- layouts/_partials/pages.html | 26 ++++++++++++++++++++++++++ layouts/_partials/taxonomy-url.html | 11 +++++++++++ layouts/_partials/terms.html | 18 ++++++++++++++++++ layouts/articles/page.html | 14 ++++++++++++-- layouts/list.html | 17 +---------------- layouts/taxonomy.html | 19 +++++++++++++++++++ layouts/term.html | 6 ++++++ 10 files changed, 95 insertions(+), 28 deletions(-) delete mode 100644 layouts/_partials/articles/header.html create mode 100644 layouts/_partials/pages.html create mode 100644 layouts/_partials/taxonomy-url.html create mode 100644 layouts/_partials/terms.html create mode 100644 layouts/taxonomy.html create mode 100644 layouts/term.html (limited to 'layouts') diff --git a/layouts/_partials/articles/header.html b/layouts/_partials/articles/header.html deleted file mode 100644 index e415b89..0000000 --- a/layouts/_partials/articles/header.html +++ /dev/null @@ -1,8 +0,0 @@ -

{{ .Title }}

-

- {{- partial "date.html" .Date -}} - {{- if gt .Lastmod .Date -}} - — modified {{ partial "date.html" .Lastmod }} - {{- end -}} -

-
diff --git a/layouts/_partials/asset-table.html b/layouts/_partials/asset-table.html index d5e893c..df47501 100644 --- a/layouts/_partials/asset-table.html +++ b/layouts/_partials/asset-table.html @@ -6,7 +6,7 @@ have a corresponding .moddate file, e.g., assets/foo/bar.txt and assets/foo/bar.txt.moddate containing "1999-01-02". This is to preserve the modification times of files when the repository is cloned. -@context {.} resource.Resources +@context {resource.Resources} . @example: {{ partial "asset-table.html" (resources.Match "spreadsheets/*.ods") }} */}} diff --git a/layouts/_partials/assets.html b/layouts/_partials/assets.html index 6930496..8bb5d2a 100644 --- a/layouts/_partials/assets.html +++ b/layouts/_partials/assets.html @@ -1,7 +1,7 @@ {{- /* Render a list of tables of assets. -@context {.} dict Mapping from section titles to asset glob patterns. +@context {dict} . Mapping from section titles to asset glob patterns. @examle: {{ partial "assets.html" (dict "Spreadsheets" "auto/*.ods") }} */}} diff --git a/layouts/_partials/pages.html b/layouts/_partials/pages.html new file mode 100644 index 0000000..6a7dc16 --- /dev/null +++ b/layouts/_partials/pages.html @@ -0,0 +1,26 @@ +{{- /* +Renders a table of pages. + +@context {Page} . Current page. + +@example: {{ partial "page-list.html" .Pages }} +*/}} + + + + + + + + + + + {{- range .Pages }} + + + + + + {{- end }} + +
DateTitleTags
{{ partial "date.html" .Date -}}{{ .LinkTitle }}{{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
diff --git a/layouts/_partials/taxonomy-url.html b/layouts/_partials/taxonomy-url.html new file mode 100644 index 0000000..259cc9b --- /dev/null +++ b/layouts/_partials/taxonomy-url.html @@ -0,0 +1,11 @@ +{{- /* +Renders the URL of a taxonomy page. + +@context {string} taxonomy Name of the taxonomy. +@context {site} site The site. + +@example: tags +*/}} + +{{- $taxonomy := index .site.Taxonomies .taxonomy -}} +{{- $taxonomy.Page.RelPermalink -}} diff --git a/layouts/_partials/terms.html b/layouts/_partials/terms.html new file mode 100644 index 0000000..afe3a14 --- /dev/null +++ b/layouts/_partials/terms.html @@ -0,0 +1,18 @@ +{{- /* +For a given taxonomy, renders a comma-separated list of terms assigned to the page. + +@context {string} taxonomy The taxonomy. +@context {page} page The current page. + +@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }} +*/}} + +{{- $taxonomy := .taxonomy }} +{{- $page := .page }} + +{{- with $page.GetTerms $taxonomy -}} + {{- range $index, $term := . -}} + {{- if $index }}, {{ end -}} + {{ .LinkTitle }} + {{- end -}} +{{- end -}} diff --git a/layouts/articles/page.html b/layouts/articles/page.html index f56c8ea..357cc9f 100644 --- a/layouts/articles/page.html +++ b/layouts/articles/page.html @@ -1,6 +1,16 @@ {{ define "main" }} - {{ partial "articles/header.html" . }} +

{{ .Title }}

+

+ {{- partial "date.html" .Date -}} + {{- if gt .Lastmod .Date -}} + — modified {{ partial "date.html" .Lastmod }} + {{- end -}} +
+ {{- if .Page.GetTerms "tags" }} + Tags: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) -}}. + {{- end }} +

+
{{ .Content }} {{ partial "assets" .Params.Assets }} - {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }} {{ end }} diff --git a/layouts/list.html b/layouts/list.html index 8c2a19f..43c0bc4 100644 --- a/layouts/list.html +++ b/layouts/list.html @@ -1,19 +1,4 @@ {{ define "main" }}

{{ .Title }}

- - - - - - - - - {{ range .Pages }} - - - - - {{ end }} - -
DateTitle
{{ partial "date.html" .Date -}}{{ .LinkTitle }}
+ {{ partial "pages.html" . }} {{ end }} diff --git a/layouts/taxonomy.html b/layouts/taxonomy.html new file mode 100644 index 0000000..ef791e8 --- /dev/null +++ b/layouts/taxonomy.html @@ -0,0 +1,19 @@ +{{ define "main" }} + {{- $taxonomy := .Data -}} +

{{ .Title }}

+ {{ .Content }} + + + + + + + {{- range $taxonomy.Terms.ByCount }} + + + + + {{- end }} + +
{{ $taxonomy.Singular | humanize }}Pages
{{ .Page.Title }}{{ .Count }}
+{{ end }} diff --git a/layouts/term.html b/layouts/term.html new file mode 100644 index 0000000..2a99edb --- /dev/null +++ b/layouts/term.html @@ -0,0 +1,6 @@ +{{ define "main" }} + {{- $term := .Data -}} +

Pages with {{ $term.Singular | humanize }} ‘{{ .Title }}’

+ {{ .Content }} + {{- partial "pages.html" . -}} +{{ end }} -- cgit v1.2.3