{{- /* navigation-series.html (partial): Displays navigational links to the next and previous parts of a series, based on `series` and `weight` frontmatter parameters. Features: - Filters pages belonging to the same series as the current page. - Sorts these series pages based on their `weight` frontmatter parameter. - Displays button-styled links to the next page (higher weight) and the previous page (lower weight) in the series. - Renders nothing if the current page is not part of a series or if series pages cannot be determined. Client-Side Navigation Optimization: - If `prefetch_enabled = true` is set in `config/_default/params.toml`: The "Previous Part" link is prefetched and the "Next Part" link is prerendered to improve perceived navigation speed. Repo: https://github.com/oxypteros/alpha */ -}} {{- $currentPage := . }} {{- $currentSeries := .Page.Params.series }} {{- $currentWeight := .Page.Params.weight | int }} {{ if not $currentSeries }} {{/* If there's no current series, don't show navigation */}} {{ else }} {{- $seriesPages:= where site.Pages "Params.series" $currentSeries }} {{- $sortedPages := sort $seriesPages "Params.weight" "asc" }} {{- if gt (len $sortedPages) 0 }} {{- $nextPost := "" }} {{- $prevPost := "" }} {{- $pageIndex := -1 }} {{- range $index, $page := $sortedPages }} {{- if eq $page.Permalink $currentPage.Permalink }} {{- $pageIndex = $index }} {{- end }} {{- end }} {{- if ne $pageIndex -1 }} {{- if lt $pageIndex (sub (len $sortedPages) 1) }} {{- $nextPost = index $sortedPages (add $pageIndex 1) }} {{- end }} {{- if gt $pageIndex 0 }} {{- $prevPost = index $sortedPages (sub $pageIndex 1) }} {{- end }} {{- end }}
{{- end }} {{- end }}