Skip to content

Commit 1de2b07

Browse files
authored
add custom table of contents for use with catalog (#63)
1 parent 1fc0e72 commit 1de2b07

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

layouts/partials/catalog-toc.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{/* Parse param from front matter */}}
2+
{{ $dataPath := split .Params.catalogType "." }}
3+
{{ $data := .Site.Data }}
4+
{{range $dataPath}}
5+
{{ $data = index $data . }}
6+
{{ end }}
7+
<nav id="TableOfContents">
8+
<ul>
9+
{{ range $data }}
10+
{{/* Render catalog toc list */}}
11+
<li>
12+
<a href="#{{.name}}">{{.name}}</a>
13+
</li>
14+
{{ end }}
15+
</ul>
16+
</nav>

layouts/partials/toc.html

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
<nav class="bd-links" aria-label="Main navigation">
2-
32
<div class="bd-toc-item active">
4-
53
<h3 class="bd-toc-link">What's on This Page</h3>
6-
7-
{{ with .TableOfContents }}
8-
9-
{{ . }}
10-
4+
{{ if .Params.catalogType }}
5+
{{ partial "catalog-toc" . }}
6+
{{ else }}
7+
{{ with .TableOfContents }}
8+
{{ . }}
9+
{{ end }}
1110
{{ end }}
12-
1311
</div>
14-
</nav>
15-
16-
17-
18-
12+
</nav>

0 commit comments

Comments
 (0)