Skip to content

Commit

Permalink
Fix handling of pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
markdumay committed Jan 2, 2025
1 parent c8af80a commit b88b176
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
12 changes: 9 additions & 3 deletions assets/js/critical/languageSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand All @@ -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
Expand All @@ -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
}
}
})
})()
Expand Down
2 changes: 2 additions & 0 deletions layouts/partials/assets/card-group.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
6 changes: 3 additions & 3 deletions layouts/partials/head/opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
14 changes: 8 additions & 6 deletions layouts/partials/head/seo.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit b88b176

Please sign in to comment.