{{/* Get the first regular page for a given section recursivelly respecting the ordering of each intermediate section. Expects a section -- NOT A REGULAR PAGE -- to be given as argument, will raise an error otherwise. Returns a regular page. If none can be found, raises an error. Example usages from a regular page: - Last page of comic : {{ partial "func/FirstPageRecursive.html" .FirstSection }} - Last page of chapter : {{ partial "func/FirstPageRecursive.html" .Parent }} */}} {{/* As a note: using `index .FirstSection.RegularPagesRecursive 0` would be unsafe. RegularPagesRecursive uses the default sort order on all found pages regardless of parent pages. Given the following pages, weight and title : - comic/ - chapter_1/: - page_1 (weight 10, title "Prologue - Page 1") - page_2 (weight 20, title "Prologue - Page 2") - ... - ... - chapter_7/: - page_1 (weight 10, title "Ending - Page 1") - page_2 (weight 20, title "Ending - Page 2") Using `index .FirstSection.RegularPagesRecursive 0` would give chapter_7/page_1 as first page! Hugo's ordering is done by *weight* asc., then *date* desc., then *title* asc., then *path* asc.. Thus, final order would be : - chapter_2/page_1: weight 10, title "Ending - Page 1" - because 10 = 10 and E < P - chapter_1/page_1: weight 10, title "Prologue - Page 1" - because 10 < 20 - chapter_2/page_2: weight 20, title "Ending - Page 2" - because 20 = 20 and E < P - chapter_1/page_2: weight 20, title "Prologue - Page 2" */}} {{ if .IsPage }} {{ errorf "'func/FirstPageRecursive' page argument must be a section, not a regular page" }} {{ end }} {{ if eq .Pages.Len 0 }} {{ errorf "Section '%s' contains no pages!" .Path }} {{ end }} {{ $first_page := index .Pages 0 }} {{ if $first_page.IsSection }} {{ $first_page = partial "func/FirstPageRecursive.html" $first_page }} {{ end }} {{ return $first_page }}