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
}
} 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
}
}
})
})()

View File

@@ -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 }}
<!-- Initialize list elements -->

View File

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

View File

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

4
package-lock.json generated
View File

@@ -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",

View File

@@ -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",