Fix handling of pagination

This commit is contained in:
Mark Dumay
2025-01-02 06:30:46 +01:00
parent c8af80ab86
commit b88b17642d
6 changed files with 25 additions and 15 deletions

View File

@@ -25,7 +25,10 @@
window.location.href = href window.location.href = href
} }
} else { } 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') alias = link.getAttribute('href')
} }
if (alias !== '') { if ((alias !== '') && (window.location.href !== alias)) {
window.location.href = alias window.location.href = alias
} else if (languageItems.length > 0) { } else if (languageItems.length > 0) {
// Redirect if the stored language differs from the active language // Redirect if the stored language differs from the active language
@@ -77,7 +80,10 @@
// Redirect to the localized homepage // Redirect to the localized homepage
const defaultLang = '{{ site.LanguageCode | default site.Language.Lang }}' const defaultLang = '{{ site.LanguageCode | default site.Language.Lang }}'
let language = storedLanguage ? storedLanguage : defaultLang let language = storedLanguage ? storedLanguage : defaultLang
window.location.href = folder + language + '/' let target = folder + language + '/'
if (window.location.href !== target) {
window.location.href = target
}
} }
}) })
})() })()

View File

@@ -67,6 +67,8 @@
{{ $paginator = $args.page.Paginate $list }} {{ $paginator = $args.page.Paginate $list }}
{{ end }} {{ end }}
{{ $list = first $paginator.PagerSize (after (mul (sub $paginator.PageNumber 1) $paginator.PagerSize) $list) }} {{ $list = first $paginator.PagerSize (after (mul (sub $paginator.PageNumber 1) $paginator.PagerSize) $list) }}
{{ page.Store.Set "paginator" $paginator }}
{{ end }} {{ end }}
<!-- Initialize list elements --> <!-- Initialize list elements -->

View File

@@ -3,9 +3,9 @@
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}"> <meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
<meta property="og:title" content="{{ $.Scratch.Get "title" }}"> <meta property="og:title" content="{{ $.Scratch.Get "title" }}">
<meta property="og:description" content="{{ $.Scratch.Get "description" }}"> <meta property="og:description" content="{{ $.Scratch.Get "description" }}">
{{ if $.Scratch.Get "paginator" -}} {{ $paginator := $.Store.Get "paginator" }}
{{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "blog" ) -}} {{ if $paginator }}
<meta property="og:url" content="{{ .Paginator.URL | absURL }}"> <meta property="og:url" content="{{ $paginator.URL | absURL }}">
{{ else -}} {{ else -}}
<meta property="og:url" content="{{ .Permalink }}"> <meta property="og:url" content="{{ .Permalink }}">
{{ end -}} {{ end -}}

View File

@@ -63,13 +63,15 @@
<meta name="description" content="{{ $.Scratch.Get "description" }}"> <meta name="description" content="{{ $.Scratch.Get "description" }}">
{{ if $.Scratch.Get "paginator" }}
<link rel="canonical" href="{{ .Paginator.URL | absURL }}"> {{ $paginator := $.Store.Get "paginator" }}
{{ if .Paginator.HasPrev -}} {{ if $paginator }}
<link rel="prev" href="{{ .Paginator.Prev.URL | absURL }}"> <link rel="canonical" href="{{ $paginator.URL | absURL }}">
{{ if $paginator.HasPrev -}}
<link rel="prev" href="{{ $paginator.Prev.URL | absURL }}">
{{ end -}} {{ end -}}
{{ if .Paginator.HasNext -}} {{ if $paginator.HasNext -}}
<link rel="next" href="{{ .Paginator.Next.URL | absURL }}"> <link rel="next" href="{{ $paginator.Next.URL | absURL }}">
{{ end -}} {{ end -}}
{{ end -}} {{ end -}}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.27.20", "version": "0.27.21",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.27.20", "version": "0.27.21",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@fullhuman/postcss-purgecss": "^7.0.2", "@fullhuman/postcss-purgecss": "^7.0.2",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@gethinode/hinode", "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", "description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
"keywords": [ "keywords": [
"hugo", "hugo",