From 63ab6f30718f83bb840b95773b612876f3326f88 Mon Sep 17 00:00:00 2001 From: yann64 Date: Sun, 11 Oct 2026 20:56:58 +0200 Subject: [PATCH] News and author pages: listPosts per page, with pager Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YDRjtmAiNpo5mK5N3d7QwZ --- README.md | 3 ++- assets/css/main.css | 4 ++++ hugo.toml | 4 +++- layouts/_partials/pager.html | 12 ++++++++++++ layouts/author/term.html | 4 +++- layouts/post/section.html | 4 +++- 6 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 layouts/_partials/pager.html diff --git a/README.md b/README.md index 553ae24b..e83aeca8 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ links to `/author//`, which lists all posts by that author. For a banner, image under `static/media/` and set `banner: /media/....jpg` (`image:` works too). Write the text in Markdown and remove `draft: true` to publish. The most recent posts (`homePosts` in `hugo.toml`, 5 by default) appear on the home page with their banner, date, author and summary (`summary:` in the front matter, or the text before -``, or the first lines); all posts are listed under News. Posts are never touched by +``, or the first lines); all posts are listed under News and on each +author's page, `listPosts` per page (20 by default). Posts are never touched by `make content`. ## Search diff --git a/assets/css/main.css b/assets/css/main.css index cca1ad7e..cba51ae4 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -158,3 +158,7 @@ table { border-collapse: collapse; } --pagefind-ui-scale: 0.85; } #search mark { background: none; color: inherit; font-weight: 700; } + +.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 24px 0 0; } +.pager a, .pager .current { padding: 4px 10px; border: 1px solid var(--line); border-radius: 4px; text-decoration: none; background: var(--panel); } +.pager .current { font-weight: 700; border-color: var(--accent); } diff --git a/hugo.toml b/hugo.toml index 53728203..0469b27c 100644 --- a/hugo.toml +++ b/hugo.toml @@ -13,8 +13,10 @@ capitalizeListTitles = false date = ["date", ":filename", ":default"] [params] - # number of news posts summarised on the home page (the News page lists them all) + # number of news posts summarised on the home page homePosts = 5 + # number of news posts per page on the News page and on each author's page + listPosts = 20 description = "The Old-Computers.com museum of computers, consoles and pongs, rebuilt from the Wayback Machine archive." [taxonomies] diff --git a/layouts/_partials/pager.html b/layouts/_partials/pager.html new file mode 100644 index 00000000..1474d5cd --- /dev/null +++ b/layouts/_partials/pager.html @@ -0,0 +1,12 @@ +{{/* page links for a paginator; nothing when there is a single page */}} +{{ if gt .TotalPages 1 }} + +{{ end }} diff --git a/layouts/author/term.html b/layouts/author/term.html index 0987fe9c..9172259f 100644 --- a/layouts/author/term.html +++ b/layouts/author/term.html @@ -2,7 +2,9 @@ {{ define "main" }}

{{ with site.GetPage "/post" }}{{ .Title }}{{ end }} › Authors

Posts by {{ .Title }}

+{{ $pager := .Paginate .Pages.ByDate.Reverse (site.Params.listPosts | default 20) }}
- {{ range .Pages.ByDate.Reverse }}{{ partial "post-summary.html" . }}{{ end }} + {{ range $pager.Pages }}{{ partial "post-summary.html" . }}{{ end }}
+{{ partial "pager.html" $pager }} {{ end }} diff --git a/layouts/post/section.html b/layouts/post/section.html index 9a55e564..6fbb58e6 100644 --- a/layouts/post/section.html +++ b/layouts/post/section.html @@ -1,7 +1,9 @@ {{ define "main" }}

{{ .Title }}

{{ .Content }}
+{{ $pager := .Paginate .RegularPages.ByDate.Reverse (site.Params.listPosts | default 20) }}
- {{ range .RegularPages.ByDate.Reverse }}{{ partial "post-summary.html" . }}{{ end }} + {{ range $pager.Pages }}{{ partial "post-summary.html" . }}{{ end }}
+{{ partial "pager.html" $pager }} {{ end }}