{{ partial "course/sidebar-menu.html" (dict "context" .) }}
{{ if not (eq .RelPermalink "/course/") }} {{ partial "documentation/breadcrumbs" . }} {{ end }}
{{ partial "article-content.html" . }} {{ $parent := .Parent }} {{ if or (eq .Params.isLesson true) (eq $parent.Params.isLesson true) }}
{{/* Determine the course section */}} {{ $subject := "" }} {{ if eq .Params.isLesson true }} {{/* Current page is a lesson (_index.md), parent is the course section */}} {{ $subject = .Parent }} {{ else }} {{/* Current page is inside a lesson, grandparent is the course section */}} {{ $subject = .Parent.Parent }} {{ end }} {{/* Build ordered list: sort lessons by weight, then sort children within each lesson */}} {{ $allLessons := sort (where $subject.Pages ".Params.isLesson" true) ".Params.weight" }} {{ $allPages := slice }} {{ range $lesson := $allLessons }} {{ $allPages = $allPages | append $lesson }} {{ $sortedChildren := sort $lesson.RegularPages ".Params.weight" }} {{ range $child := $sortedChildren }} {{ $allPages = $allPages | append $child }} {{ end }} {{ end }} {{/* Find current page position in the ordered list */}} {{ $currentPage := . }} {{ $currentIndex := -1 }} {{ range $idx, $page := $allPages }} {{ if eq $page.RelPermalink $currentPage.RelPermalink }} {{ $currentIndex = $idx }} {{ end }} {{ end }} {{/* Get next page by index */}} {{ $nextIndex := add $currentIndex 1 }} {{ if lt $nextIndex (len $allPages) }} {{ $next := index $allPages $nextIndex }} {{/* Determine if current page is last in its day (for button text) */}} {{ $siblings := $currentPage.Parent.RegularPages }} {{ $maxWeight := 0 }} {{ range $p := $siblings }} {{ $pWeight := 0 }} {{ if $p.Params.weight }} {{ $pWeight = int $p.Params.weight }} {{ end }} {{ if gt $pWeight $maxWeight }} {{ $maxWeight = $pWeight }} {{ end }} {{ end }} {{ $currentWeight := 0 }} {{ if $currentPage.Params.weight }} {{ $currentWeight = int $currentPage.Params.weight }} {{ end }} {{ if eq $currentWeight $maxWeight }} {{ $subject.Params.content.nextDay }} {{ .Parent.Title }} {{ else }} {{ $subject.Params.content.nextButton }} {{ end }} {{ end }}
{{ end }}
{{ partial "table-of-contents" . }} {{ partial "documentation/footer.html" . }}