show TOC in sidebar if frontmatter param toc == true
This commit is contained in:
parent
42c48978bb
commit
3de565007a
5 changed files with 25 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ public
|
|||
resources
|
||||
themes
|
||||
static/img
|
||||
.hugo_build.lock
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# de.yaml 2021-11-24
|
||||
# de.yaml 2022-01-06
|
||||
#
|
||||
|
||||
about:
|
||||
|
@ -74,6 +74,9 @@ sibling-articles:
|
|||
Teaser:
|
||||
other: Hintergrund
|
||||
|
||||
toc:
|
||||
other: Inhaltsverzeichnis
|
||||
|
||||
topics:
|
||||
other: Themen
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# en.yaml 2021-11-24
|
||||
# en.yaml 2022-01-06
|
||||
#
|
||||
|
||||
about:
|
||||
|
@ -75,6 +75,9 @@ sibling-articles:
|
|||
Teaser:
|
||||
other: Teaser
|
||||
|
||||
toc:
|
||||
other: Contents
|
||||
|
||||
topics:
|
||||
other: Topics
|
||||
|
||||
|
|
|
@ -69,4 +69,15 @@
|
|||
(dict "related" $related "header" $header "id" "articles-in-section") -}}
|
||||
{{- end }}
|
||||
|
||||
{{ if .Params.toc -}}
|
||||
<div class="card mt-3">
|
||||
<div class="card-header">
|
||||
<h4 class="card-text">{{i18n "toc"}}</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{{ .TableOfContents }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end -}}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
{{- $pages := where .Site.RegularPages "Params.pageid" "eq" (.Get "pid") -}}
|
||||
{{- $frag := .Get "id" -}}
|
||||
{{- $fragsep := "" -}}
|
||||
{{- if ne $frag "" -}}{{- $fragsep = "#" -}}{{- end -}}
|
||||
{{- $inner := .Inner -}}
|
||||
{{- range $pages -}}
|
||||
<a href="{{ .Permalink }}">{{ or $inner .Title | markdownify }}</a>
|
||||
{{- $url := printf "%s%s%s" .Permalink $fragsep $frag -}}
|
||||
<a href="{{ $url }}">{{ or $inner .Title | markdownify }}</a>
|
||||
{{- end -}}
|
||||
|
|
Loading…
Add table
Reference in a new issue