From b9de43b354b9eae95d8ba8a8792d23a58c67a801 Mon Sep 17 00:00:00 2001 From: Simon Hammes Date: Wed, 9 Apr 2025 14:42:54 +0200 Subject: [PATCH] Enable pagination --- src/config/_default/hugo.toml | 25 ++++---- .../seatable/layouts/_default/list.html | 8 ++- .../seatable/layouts/partials/pagination.html | 57 +++++++++++++++++++ 3 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 src/themes/seatable/layouts/partials/pagination.html diff --git a/src/config/_default/hugo.toml b/src/config/_default/hugo.toml index 1c24e166b..2b4d4cd81 100644 --- a/src/config/_default/hugo.toml +++ b/src/config/_default/hugo.toml @@ -7,22 +7,25 @@ enableGitInfo = true # FIXME: klären, ob das lokal auskommentiert werden kann, weil ich in build.sh ja lastmod mitgebe... [frontmatter] - lastmod = ["lastmod", ":git", "date", "publishDate"] +lastmod = ["lastmod", ":git", "date", "publishDate"] [sitemap] - changeFreq = 'daily' - filename = 'sitemap.xml' - priority = 0.5 +changeFreq = 'daily' +filename = 'sitemap.xml' +priority = 0.5 [outputs] - home = ["HTML", "RSS", "JSON", "post-sitemap", "page-sitemap"] +home = ["HTML", "RSS", "JSON", "post-sitemap", "page-sitemap"] [outputFormats.post-sitemap] - baseName = 'post-sitemap' - mediaType = 'application/xml' - noUgly = true +baseName = 'post-sitemap' +mediaType = 'application/xml' +noUgly = true [outputFormats.page-sitemap] - baseName = 'page-sitemap' - mediaType = 'application/xml' - noUgly = true +baseName = 'page-sitemap' +mediaType = 'application/xml' +noUgly = true + +[pagination] +pagerSize = 15 diff --git a/src/themes/seatable/layouts/_default/list.html b/src/themes/seatable/layouts/_default/list.html index f3b4b9254..58652c134 100644 --- a/src/themes/seatable/layouts/_default/list.html +++ b/src/themes/seatable/layouts/_default/list.html @@ -8,7 +8,11 @@

{{ .T
- {{ range $index, $page := .Pages }} + {{ $pages := .Pages }} + {{ $paginator := .Paginate $pages.ByDate.Reverse }} + + + {{ range $index, $page := $paginator.Pages }} {{ if eq $index 0 }} @@ -63,6 +67,8 @@

{{ $page.Title }}

{{ end }} {{ end }} + + {{ partial "pagination.html" . }}
diff --git a/src/themes/seatable/layouts/partials/pagination.html b/src/themes/seatable/layouts/partials/pagination.html new file mode 100644 index 000000000..cbc201896 --- /dev/null +++ b/src/themes/seatable/layouts/partials/pagination.html @@ -0,0 +1,57 @@ +{{- $page := . }} +{{ $classes := "ms-0 flex h-10 items-center justify-center rounded-s-lg border border-e-0 border-gray-300 bg-white px-4 leading-tight text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white" }} + +{{- if gt $page.Paginator.TotalPages 1 }} + +{{- end }}