Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zwbetz-gh/cupper-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzwbetz-gh <zwbetz@gmail.com>2021-09-12 22:24:53 +0300
committerzwbetz-gh <zwbetz@gmail.com>2021-09-12 22:24:53 +0300
commit87e1a8608f44d46f6cc34fc54a4ddadbd2999433 (patch)
treeae7d5957cc1b8c2dadd6185144c8377527d2cf21 /layouts
parentb87a99af1fe064a574ba385a9f11334f4296f314 (diff)
use hugo's toc
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/toc.html19
-rw-r--r--layouts/post/single.html6
2 files changed, 5 insertions, 20 deletions
diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html
index 55a2ccb..cdb0d7c 100644
--- a/layouts/partials/toc.html
+++ b/layouts/partials/toc.html
@@ -1,19 +1,6 @@
-{{ $headings := findRE "<h2.*?>(.|\n])+?</h2>" .Content }}
-{{ if ge (len $headings) 2 }}
+{{ if eq .Params.toc true }}
<nav class="toc" aria-labelledby="toc-heading">
- <h2 id="toc-heading">{{ T "table_of_contents" }}</h2>
- <ol>
- {{ range $headings }}
- <li>
- {{ $id := findRE "id=\".*\"" . }}
- {{ $id = index $id 0 }}
- {{ $id = strings.TrimPrefix "id=\"" $id }}
- {{ $id = strings.TrimSuffix "\"" $id }}
- <a href="#{{ $id }}">
- {{ . | htmlUnescape | plainify }}
- </a>
- </li>
- {{ end }}
- </ol>
+ <strong id="toc-heading">{{ T "table_of_contents" }}</strong>
+ {{ .TableOfContents }}
</nav>
{{ end }}
diff --git a/layouts/post/single.html b/layouts/post/single.html
index 9003db6..38512f6 100644
--- a/layouts/post/single.html
+++ b/layouts/post/single.html
@@ -35,10 +35,8 @@
</ul>
</div>
{{ end }}
-
- {{ if ne .Params.toc false }}
- {{ partial "toc" . }}
- {{ end }}
+
+ {{ partial "toc.html" . }}
{{ .Content }}
</main>