Allow disabling header anchors with page and element params
Set params.renderHeadingAnchors = false to disable for a whole page. Set the element attribute anchor = false to disable for a single heading.
This commit is contained in:
parent
6d0fd81a7b
commit
576e7cb485
1 changed files with 6 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
<h{{ .Level }} id="{{ .Anchor }}" class="heading">
|
<h{{ .Level }} id="{{ .Anchor }}" class="heading">
|
||||||
{{ .Text | safeHTML }} <a class="heading__anchor" href="#{{ .Anchor }}">#</a>
|
{{ .Text | safeHTML }}
|
||||||
|
{{- $pageWantsAnchors := .Page.Params.renderHeadingAnchors | default true -}}
|
||||||
|
{{- $anchorEnabledForThisHeading := .Attributes.anchor | default true -}}
|
||||||
|
{{- if and $pageWantsAnchors $anchorEnabledForThisHeading -}}
|
||||||
|
<a class="heading__anchor" href="#{{ .Anchor }}">#</a>
|
||||||
|
{{- end -}}
|
||||||
</h{{ .Level }}>
|
</h{{ .Level }}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue