diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-02 11:14:24 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-02 11:14:24 +0800 |
commit | a70083fb23ad51dde285d55b6792beab4021fc89 (patch) | |
tree | 52c33668b50c8b8858da782f640d5fc752bc6802 /layouts/partials | |
parent | Fix nav state (diff) | |
download | website-a70083fb23ad51dde285d55b6792beab4021fc89.tar.gz website-a70083fb23ad51dde285d55b6792beab4021fc89.tar.zst website-a70083fb23ad51dde285d55b6792beab4021fc89.zip |
Recursive navigation
Diffstat (limited to '')
-rw-r--r-- | layouts/partials/recursive_nav.html | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/layouts/partials/recursive_nav.html b/layouts/partials/recursive_nav.html new file mode 100644 index 0000000..4a3ed2c --- /dev/null +++ b/layouts/partials/recursive_nav.html @@ -0,0 +1,12 @@ +{{ $currentPage := .currentPage }} +<ul> + {{ range .pages }} + {{ $isCurrentOrAncestor := or (eq $currentPage .) ($currentPage.IsDescendant .) }} + <li {{ if eq $currentPage . }}class="nav-current"{{ end }}> + <a href="{{ .RelPermalink }}">{{ .Title }}</a> + </li> + {{ if and .Pages $isCurrentOrAncestor }} + {{ partial "recursive_nav.html" (dict "currentPage" $currentPage "pages" .Pages) }} + {{ end }} + {{ end }} +</ul> |