{{/* Get the first leaf section for a given section, respecting the ordering of each intermediate section. If there is no sub-section to the given section, returns the given section itself. Expects a section -- NOT A REGULAR PAGE -- to be given as argument, will raise an error otherwise. Returns a Section. Example usage from a regular page: - Last chapter of a comic : {{ partial "func/FirstLeafSectionRecursive.html" .FirstSection }} */}} {{ if .IsPage }} {{ errorf "'func/FirstLeafSectionRecursive' page argument must be a section, not a regular page" }} {{ end }} {{ $last_section := . }} {{ $sub_sections := where .Section }} {{ if gt $sub_sections.Len 0 }} {{ $last_sub_section := index $sub_sections 0 }} {{ $last_section = partial "func/FirstLeafSectionRecursive.html" $last_sub_section }} {{ end }} {{ return $last_section }}