Feature: Add next and previous page links (#747)

* Rewrite prev-next with enw lang. selector
* Make sure next page stays on right side
* Align icon styles
This commit is contained in:
Alex Shpak
2025-07-31 23:18:41 +02:00
committed by GitHub
parent 92579b2c72
commit 9181135505
8 changed files with 67 additions and 4 deletions
+31
View File
@@ -0,0 +1,31 @@
{{ $bookSection := default "docs" .Site.Params.BookSection }}
{{ if eq $bookSection "*" }}
{{ $bookSection = "/" }}{{/* Backward compatibility */}}
{{ end }}
{{ with .Site.GetPage $bookSection }}
{{ $pages := partialCached "docs/prev-next-cache" .Pages }}
{{ $prev := $pages.Next $ }}
{{ $next := $pages.Prev $ }}
{{- if or $prev $next }}
<div class="flex flex-wrap justify-between">
<span>
{{ with $prev }}
<a href="{{ .RelPermalink }}" class="flex align-center book-icon">
<img src="{{ "svg/backward.svg" | relURL }}" class="book-icon" alt="Previous" title="{{ partial "docs/title" . }}" />
<span>{{ partial "docs/title" . }}</span>
</a>
{{ end }}
</span>
<span>
{{ with $next }}
<a href="{{ .RelPermalink }}" class="flex align-center book-icon">
<span>{{ partial "docs/title" . }}</span>
<img src="{{ "svg/forward.svg" | relURL }}" class="book-icon" alt="Next" title="{{ partial "docs/title" . }}" />
</a>
{{ end }}
</span>
</div>
{{ end -}}
{{ end }}