about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--assets/css/theme.css4
-rw-r--r--i18n/en.toml3
-rw-r--r--i18n/fr.toml3
-rw-r--r--i18n/vi.toml3
-rw-r--r--layouts/_default/list.html4
-rw-r--r--layouts/partials/post-navigation-top.html3
-rw-r--r--layouts/partials/post-navigation.html2
-rw-r--r--layouts/partials/root-toc.html8
-rw-r--r--layouts/partials/toc.html11
9 files changed, 36 insertions, 5 deletions
diff --git a/assets/css/theme.css b/assets/css/theme.css
index 1162ae0..22400e9 100644
--- a/assets/css/theme.css
+++ b/assets/css/theme.css
@@ -54,3 +54,7 @@ a.nav-prev::after {
 a.nav-next::before {
     content: "← "
 }
+
+.toc-collapse {
+    text-align: initial;
+}
diff --git a/i18n/en.toml b/i18n/en.toml
index 64ee617..5ec68db 100644
--- a/i18n/en.toml
+++ b/i18n/en.toml
@@ -14,3 +14,6 @@ other = "approximately {{ .Count }} minutes reading"
 
 [skipToContent]
 other = "Skip to main content"
+
+[toc]
+other = "Table of contents"
diff --git a/i18n/fr.toml b/i18n/fr.toml
index 42481d0..e649d59 100644
--- a/i18n/fr.toml
+++ b/i18n/fr.toml
@@ -14,3 +14,6 @@ other = "environ {{ .Count }} minutes de lecture"
 
 [skipToContent]
 other = "Aller à l'article"
+
+[toc]
+other = "Table des matières"
diff --git a/i18n/vi.toml b/i18n/vi.toml
index 97a6fc5..e5a1751 100644
--- a/i18n/vi.toml
+++ b/i18n/vi.toml
@@ -12,3 +12,6 @@ other = "đọc hết khoảng {{ .Count }} phút"
 
 [skipToContent]
 other = "Đi đến bài viết"
+
+[toc]
+other = "Mục lục"
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 9a4672e..0f104a4 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -5,13 +5,13 @@ SPDX-License-Identifier: MIT
 */}}
 
 {{ define "main" }}
-  <section class="index-content">
+  <section class="index-content" id="main">
     {{ .Content }}
   </section>
   {{ if in .Params.categories "book" }}
   {{ partial "post-navigation-top.html" . }}
   <section class="toc">
-    {{ partial "toc.html" . }}
+    {{ partial "toc.html" (dict "content" . "currentLink" .RelPermalink) }}
   </section>
   {{ else if in .Params.categories "blog" }}
     {{ partial "feed.html" . }}
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 }}