53 lines
1.6 KiB
HTML
53 lines
1.6 KiB
HTML
{{- $current := . }}
|
|
{{- $currentTitle := .Title }}
|
|
{{- $position := .Scratch.Get "paginationPosition" | default "up" }}
|
|
|
|
{{- with index .Params.dossier 0 }}
|
|
{{- $dossierID := . }}
|
|
{{- $allPages := site.RegularPages }}
|
|
{{- $filtered := where $allPages "Params.dossier" "intersect" (slice $dossierID) }}
|
|
{{- $valid := where $filtered "Weight" "gt" 0 }}
|
|
{{- $sorted := sort $valid "Weight" }}
|
|
|
|
{{- if gt (len $sorted) 1 }}
|
|
{{- $index := -1 }}
|
|
{{- range $i, $p := $sorted }}
|
|
{{- if eq $p.Permalink $current.Permalink }}
|
|
{{- $index = $i }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- $prev := index $sorted (sub $index 1) }}
|
|
{{- $next := index $sorted (add $index 1) }}
|
|
|
|
<nav class="pagination-bar dossier-pagination {{ $position }}">
|
|
<h2>{{ $dossierID }}</h2>
|
|
|
|
{{- if ge $index 1 }}
|
|
<a class="prev-page" href="{{ $prev.RelPermalink }}">← Page précédente</a>
|
|
{{- else }}
|
|
<span class="disabled prev-page">← Page précédente</span>
|
|
{{- end }}
|
|
|
|
<details class="page-select {{ $position }}">
|
|
<summary>{{ $currentTitle }}</summary>
|
|
<ul>
|
|
{{- range $i, $p := $sorted }}
|
|
<li>
|
|
{{- if eq $p.Permalink $current.Permalink }}
|
|
<span class="current">{{ $p.Title }}</span>
|
|
{{- else }}
|
|
<a href="{{ $p.RelPermalink }}">{{ $p.Title }}</a>
|
|
{{- end }}
|
|
</li>
|
|
{{- end }}
|
|
</ul>
|
|
</details>
|
|
|
|
{{- if lt (add $index 1) (len $sorted) }}
|
|
<a class="next-page" href="{{ $next.RelPermalink }}">Page suivante →</a>
|
|
{{- else }}
|
|
<span class="disabled next-page">Page suivante →</span>
|
|
{{- end }}
|
|
</nav>
|
|
{{- end }}
|
|
{{- end }} |