{{- /* For a given comic page, renders a nav bar. This navbar contains a link to the following: - first page - previous chapter (if applicable) - previous page - next page - next chapter (if applicable) - last page Chapter navigation is only shown if: - site parameter silicate.pages.show_chapter_nav is true - there is at least a comic section in the given page comic series Expect a comic page as argument. Example usage: {{ partial "comic/nav.html" . }} */}} {{- $first_page := partial "func/FirstPageRecursive.html" .FirstSection }} {{- $last_page := partial "func/LastPageRecursive.html" .FirstSection }} {{- $prev_chapter := partial "func/PrevLeafSection.html" . }} {{- $next_chapter := partial "func/NextLeafSection.html" . }} {{/* we use Reverse before Next and Prev because they use descending weight ordering instead of the default ascending order. Also, this will not cross beyond the current section / chapter, we need to go look at the prev / next chapter too if we don't directly find a page. */}} {{- $prev_page := false }} {{- $next_page := false }} {{- with .Parent.Pages.Reverse.Prev . }} {{- $prev_page = . }} {{- else with $prev_chapter }} {{- $prev_page = index .Pages.Reverse 0 }} {{- end }} {{- with .Parent.Pages.Reverse.Next . }} {{- $next_page = . }} {{- else with $next_chapter }} {{- $next_page = index .Pages 0 }} {{- end }} {{- $has_chapters := gt .FirstSection.Sections.Len 0 }} {{- $show_chapter_nav := and .Site.Params.silicate.pages.show_chapter_nav $has_chapters }} {{- $prev_chapter_first_page := false }} {{- $next_chapter_first_page := false }} {{- if $show_chapter_nav }} {{- with $prev_chapter }} {{- $prev_chapter_first_page = partial "func/FirstPageRecursive.html" . }} {{- end }} {{- with $next_chapter }} {{- $next_chapter_first_page = partial "func/FirstPageRecursive.html" . }} {{- end }} {{- end }} {{- /* As a note, the newlines and use of `{{-` with no `-}}` is important : since elements under the `nav` will be shown as `inline-block`, newline in HTML adds a litteral space between the elements. If newlines are not consistent, spaces won't be either and spacing of nav buttons will be uneven. */}}