From b88b17642d76c291aa26ac67bae91062d0327dbb Mon Sep 17 00:00:00 2001
From: Mark Dumay <61946753+markdumay@users.noreply.github.com>
Date: Thu, 2 Jan 2025 06:30:46 +0100
Subject: [PATCH] Fix handling of pagination
---
assets/js/critical/languageSelector.js | 12 +++++++++---
layouts/partials/assets/card-group.html | 2 ++
layouts/partials/head/opengraph.html | 6 +++---
layouts/partials/head/seo.html | 14 ++++++++------
package-lock.json | 4 ++--
package.json | 2 +-
6 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/assets/js/critical/languageSelector.js b/assets/js/critical/languageSelector.js
index 0a6cf852..89ffbb97 100644
--- a/assets/js/critical/languageSelector.js
+++ b/assets/js/critical/languageSelector.js
@@ -25,7 +25,10 @@
window.location.href = href
}
} else {
- window.location.href = folder + language + '/'
+ let target = folder + language + '/'
+ if (window.location.href !== target) {
+ window.location.href = target
+ }
}
}
}
@@ -50,7 +53,7 @@
alias = link.getAttribute('href')
}
- if (alias !== '') {
+ if ((alias !== '') && (window.location.href !== alias)) {
window.location.href = alias
} else if (languageItems.length > 0) {
// Redirect if the stored language differs from the active language
@@ -77,7 +80,10 @@
// Redirect to the localized homepage
const defaultLang = '{{ site.LanguageCode | default site.Language.Lang }}'
let language = storedLanguage ? storedLanguage : defaultLang
- window.location.href = folder + language + '/'
+ let target = folder + language + '/'
+ if (window.location.href !== target) {
+ window.location.href = target
+ }
}
})
})()
diff --git a/layouts/partials/assets/card-group.html b/layouts/partials/assets/card-group.html
index 8eb98934..014b62d9 100644
--- a/layouts/partials/assets/card-group.html
+++ b/layouts/partials/assets/card-group.html
@@ -67,6 +67,8 @@
{{ $paginator = $args.page.Paginate $list }}
{{ end }}
{{ $list = first $paginator.PagerSize (after (mul (sub $paginator.PageNumber 1) $paginator.PagerSize) $list) }}
+
+ {{ page.Store.Set "paginator" $paginator }}
{{ end }}
diff --git a/layouts/partials/head/opengraph.html b/layouts/partials/head/opengraph.html
index 25421c9a..6de7d126 100644
--- a/layouts/partials/head/opengraph.html
+++ b/layouts/partials/head/opengraph.html
@@ -3,9 +3,9 @@
-{{ if $.Scratch.Get "paginator" -}}
- {{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "blog" ) -}}
-
+{{ $paginator := $.Store.Get "paginator" }}
+{{ if $paginator }}
+
{{ else -}}
{{ end -}}
diff --git a/layouts/partials/head/seo.html b/layouts/partials/head/seo.html
index 36be2aeb..ce541950 100644
--- a/layouts/partials/head/seo.html
+++ b/layouts/partials/head/seo.html
@@ -63,13 +63,15 @@
-{{ if $.Scratch.Get "paginator" }}
-
- {{ if .Paginator.HasPrev -}}
-
+
+{{ $paginator := $.Store.Get "paginator" }}
+{{ if $paginator }}
+
+ {{ if $paginator.HasPrev -}}
+
{{ end -}}
- {{ if .Paginator.HasNext -}}
-
+ {{ if $paginator.HasNext -}}
+
{{ end -}}
{{ end -}}
diff --git a/package-lock.json b/package-lock.json
index 706b1752..d6f3824b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@gethinode/hinode",
- "version": "0.27.20",
+ "version": "0.27.21",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@gethinode/hinode",
- "version": "0.27.20",
+ "version": "0.27.21",
"license": "MIT",
"dependencies": {
"@fullhuman/postcss-purgecss": "^7.0.2",
diff --git a/package.json b/package.json
index d0175475..77327729 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@gethinode/hinode",
- "version": "0.27.20",
+ "version": "0.27.21",
"description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
"keywords": [
"hugo",