From 85db458aa1042a458df5c5a25d70dd06655c924a Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Thu, 10 Sep 2026 00:41:20 +0800 Subject: Add updated document archive --- content/updates/_index.md | 5 +++++ hugo.toml | 1 + layouts/partials/recent.html | 15 +++------------ layouts/partials/updated-items.html | 16 ++++++++++++++++ layouts/updates/list.html | 20 ++++++++++++++++++++ scripts/publish-raw | 4 ++++ static/style.css | 4 +++- 7 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 content/updates/_index.md create mode 100644 layouts/partials/updated-items.html create mode 100644 layouts/updates/list.html diff --git a/content/updates/_index.md b/content/updates/_index.md new file mode 100644 index 0000000..0ae5b3d --- /dev/null +++ b/content/updates/_index.md @@ -0,0 +1,5 @@ +--- +title: "UPDATES" +lang: en +description: "Journal entries and notes ordered by their latest substantive update." +--- diff --git a/hugo.toml b/hugo.toml index ed3e4d7..83d8efd 100644 --- a/hugo.toml +++ b/hugo.toml @@ -16,6 +16,7 @@ enableRobotsTXT = false sourceURL = "https://codeberg.org/Richard-Qin/rhomepage" gitBase = "https://codeberg.org/Richard-Qin/rhomepage/src/branch/main" contentLicense = "CC BY-SA 4.0" + recentLimit = 20 [frontmatter] date = ["created"] diff --git a/layouts/partials/recent.html b/layouts/partials/recent.html index 47c8332..cbe91af 100644 --- a/layouts/partials/recent.html +++ b/layouts/partials/recent.html @@ -1,18 +1,8 @@ -{{- $items := slice -}} -{{- range where site.RegularPages "Section" "journal" -}} - {{- $items = $items | append (dict "page" . "kind" "journal" "sortDate" (.Date.Format "2006-01-02")) -}} -{{- end -}} -{{- range where site.RegularPages "Section" "notes" -}} - {{- $page := . -}} - {{- with $page.Params.recent -}} - {{- $items = $items | append (dict "page" $page "kind" "note" "sortDate" (time.Format "2006-01-02" .)) -}} - {{- end -}} -{{- end -}} -{{- $items = sort $items "sortDate" "desc" -}} +{{- $items := partial "updated-items.html" . -}}

RECENT

    - {{- range $items }} + {{- range first site.Params.recentLimit $items }}
  1. [{{ .kind }}] @@ -20,4 +10,5 @@
  2. {{- end }}
+

Read more

diff --git a/layouts/partials/updated-items.html b/layouts/partials/updated-items.html new file mode 100644 index 0000000..5f738a8 --- /dev/null +++ b/layouts/partials/updated-items.html @@ -0,0 +1,16 @@ +{{- $items := slice -}} +{{- range $section := slice "journal" "notes" -}} + {{- $kind := cond (eq $section "notes") "note" "journal" -}} + {{- range where site.RegularPages "Section" $section -}} + {{- if not .Params.created -}} + {{- errorf "Missing required created date in %s" .File.Path -}} + {{- end -}} + {{- if not .Params.updated -}} + {{- errorf "Missing required updated date in %s" .File.Path -}} + {{- end -}} + {{- $sortDate := time.Format "2006-01-02" .Params.updated -}} + {{- $sortKey := printf "%s|%s" $sortDate .RelPermalink -}} + {{- $items = $items | append (dict "page" . "kind" $kind "sortDate" $sortDate "sortKey" $sortKey) -}} + {{- end -}} +{{- end -}} +{{- return (sort $items "sortKey" "desc") -}} diff --git a/layouts/updates/list.html b/layouts/updates/list.html new file mode 100644 index 0000000..125ba79 --- /dev/null +++ b/layouts/updates/list.html @@ -0,0 +1,20 @@ +{{ define "main" }} +
+
+

{{ .Title }}

+
+ {{ .Content }} + {{- $items := partial "updated-items.html" . -}} +
+
    + {{- range $items }} +
  1. + + [{{ .kind }}] + {{ .page.LinkTitle }} +
  2. + {{- end }} +
+
+
+{{ end }} diff --git a/scripts/publish-raw b/scripts/publish-raw index 09048f3..cc9b02b 100755 --- a/scripts/publish-raw +++ b/scripts/publish-raw @@ -13,6 +13,10 @@ do relative=${source#"$content_dir"/} case "$relative" in + updates/_index.md) + # Updates is an aggregate index, not a published Markdown document. + continue + ;; journal/_index.md) target=$public_dir/journal/_index.md ;; diff --git a/static/style.css b/static/style.css index a799090..cf033de 100644 --- a/static/style.css +++ b/static/style.css @@ -249,7 +249,8 @@ a:focus-visible { margin-bottom: 0.7rem; } -.recent .document-list li { +.recent .document-list li, +.updates-list .document-list li { display: grid; grid-template-columns: max-content max-content minmax(0, 1fr); gap: 0.25rem 0.8rem; @@ -495,6 +496,7 @@ img { } .recent .document-list li, + .updates-list .document-list li, .journal-list li { display: block; } -- cgit v1.2.3