Browse Source

feat(feature/table-of-contents): add option to start with disclosure open

Josh Habdas 1 year ago
parent
commit
a299b8bc47
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74

+ 2
- 1
docs/content/feature/table-of-contents.id.md View File

@@ -9,7 +9,8 @@ feature = ["related content", "snippets", "code highlighter"]
9 9
 Secara otomatis menghasilkan daftar isi dengan tautan gulir halus berdasarkan {{< external href="https://gsnedders.html5.org/outliner/" text="page outline" />}} saat ini. Untuk melakukannya tambahkan yang berikut ini ke postingan {{< external href="https://gohugo.io/content-management/front-matter/" text="Front Matter" />}}:
10 10
 
11 11
 ```toml
12
-toc = true
12
+toc = true # display collapsed
13
+toc = "open" # display expanded
13 14
 ```
14 15
 
15 16
 Atur `false`, atau cukup hapus pengaturan untuk menonaktifkan.

+ 3
- 2
docs/content/feature/table-of-contents.md View File

@@ -6,10 +6,11 @@ tags = ["metadata"]
6 6
 features = ["related content", "snippets", "code highlighter"]
7 7
 +++
8 8
 
9
-Automatically generate a table of contents with smooth-scroll links based on the current {{< external href="https://gsnedders.html5.org/outliner/" text="page outline" />}}. To do so add the following to post {{< external href="https://gohugo.io/content-management/front-matter/" text="Front Matter" />}}:
9
+Automatically generate a table of contents with smooth-scroll links based on the {{< external href="https://gsnedders.html5.org/outliner/" text="page outline" />}}. To do so add one of the following to post {{< external href="https://gohugo.io/content-management/front-matter/" text="Front Matter" />}}:
10 10
 
11 11
 ```toml
12
-toc = true
12
+toc = true # display collapsed
13
+toc = "open" # display expanded
13 14
 ```
14 15
 
15 16
 Set `false`, or simply remove the setting, to disable.

+ 3
- 3
layouts/partials/toc-maybe.html View File

@@ -1,6 +1,6 @@
1
-{{ if and (isset .Params "toc") .Params.toc }}
2
-  <details>
1
+{{ with .Params.toc }}
2
+  <details{{ if eq . "open" }} open{{ end }}>
3 3
     <summary>Table of Contents</summary>
4
-    {{ .TableOfContents }}
4
+    {{ $.TableOfContents }}
5 5
   </details>
6 6
 {{ end }}

Loading…
Cancel
Save