diff options
Diffstat (limited to 'layouts/partials')
-rw-r--r-- | layouts/partials/post-navigation-top.html | 3 | ||||
-rw-r--r-- | layouts/partials/post-navigation.html | 2 | ||||
-rw-r--r-- | layouts/partials/root-toc.html | 8 | ||||
-rw-r--r-- | layouts/partials/toc.html | 11 |
4 files changed, 21 insertions, 3 deletions
diff --git a/layouts/partials/post-navigation-top.html b/layouts/partials/post-navigation-top.html index 3bcc39f..a7470c0 100644 --- a/layouts/partials/post-navigation-top.html +++ b/layouts/partials/post-navigation-top.html @@ -1,2 +1,5 @@ +{{ if or (in .Params.categories "book") (in .CurrentSection.Params.categories "book") }} {{ partial "breadcrumbs.html" .}} +{{ partial "root-toc.html" .}} +{{ end}} {{ partial "post-navigation.html" .}} diff --git a/layouts/partials/post-navigation.html b/layouts/partials/post-navigation.html index b88d91f..edd1333 100644 --- a/layouts/partials/post-navigation.html +++ b/layouts/partials/post-navigation.html @@ -1,3 +1,4 @@ +{{ if not .IsSection}} <nav> {{ if .NextInSection }} <a class="nav-next" href="{{ .NextInSection.RelPermalink }}">{{ .NextInSection.Title }}</a> @@ -7,3 +8,4 @@ <a class="nav-prev"href="{{ .PrevInSection.RelPermalink }}">{{ .PrevInSection.Title }}</a> {{ end }} </nav> +{{ end }} diff --git a/layouts/partials/root-toc.html b/layouts/partials/root-toc.html new file mode 100644 index 0000000..2792ce9 --- /dev/null +++ b/layouts/partials/root-toc.html @@ -0,0 +1,8 @@ + <details class="toc-collapse"> + <summary>{{ i18n "toc" }}</summary> + {{ $currentLink := .RelPermalink }} + {{ range last 1 (where .Ancestors "Params.categories" "intersect" (slice "book") ) }} + <a href="{{ .RelPermalink }}">{{ .Title }}</a> + {{ partial "toc.html" (dict "content" . "currentLink" $currentLink) }} + {{ end }} + </details> diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html index 607e7f0..3b5a822 100644 --- a/layouts/partials/toc.html +++ b/layouts/partials/toc.html @@ -1,4 +1,5 @@ -{{ $chapters := .Page.Pages }} +{{ $chapters := .content.Page.Pages }} +{{ $currentLink := .currentLink}} {{ range .Page.Translations }} {{ $chapters = $chapters | lang.Merge .Pages }} {{ end}} @@ -9,10 +10,14 @@ {{ with .Params.chapterName }} {{ $fullTitle = printf "%s – %s" $fullTitle . }} {{ end }} - <a href="{{ .RelPermalink }}">{{ trim $fullTitle " " }}</a> + {{ if eq $currentLink .RelPermalink }} + <a aria-current="page">{{ trim $fullTitle " " }}</a> ({{ i18n "current"}}) + {{ else }} + <a href="{{ .RelPermalink }}">{{ trim $fullTitle " " }}</a> + {{ end }} {{ partial "post-info.html" . }} {{ if .IsSection}} - {{ partial "toc.html" . }} + {{ partial "toc.html" (dict "content" . "currentLink" $currentLink) }} {{ end }} </li> {{ end }} |