{{- define "nav-tree" }} {{- $section := .section }} {{- $currentPage := .currentPage }} {{- /* セクションページ */}} {{ $section.URL }} {{- if $section.InSection $currentPage }}true{{- end }} {{- if $section.IsAncestor $currentPage }}true{{- end }} {{- if $section.IsDescendant $currentPage }}true{{- end }} {{- /* カレントセクション直下のページリスト(ホームだけ特殊処理) */}} {{- range (cond $section.IsHome (where $section.Site.RegularPages "Section" "") $section.Pages) }} {{ .URL }} {{- if .InSection $currentPage }}true{{- end }} {{- if .IsAncestor $currentPage }}true{{- end }} {{- if .IsDescendant $currentPage }}true{{- end }} {{- end }} {{- /* カレントセクション直下のセクションは再帰処理 */}} {{- range $section.Sections }} {{- template "nav-tree" (dict "section" . "currentPage" $currentPage) }} {{- end }} {{- end }} {{/* 全てのセクションとページをループ処理 */}} {{ range where .Site.Pages ".Kind" "in" (slice "home" "section" "page") }}

$p2 = {{ .URL }}

{{- template "nav-tree" (dict "section" .Site.Home "currentPage" .) }}
$p1.URL $p1.InSection $p2 $p1.IsAncestor $p2 $p1.IsDescendant $p2
{{ end }}