Instead of a single hash in the left gutter, draw <n> hashes where <n> is the heading level. All of these hashes are part of the anchor text.
11 lines
512 B
HTML
11 lines
512 B
HTML
{{- $pageWantsAnchors := .Page.Params.renderHeadingAnchors | default true -}}
|
|
{{- $anchorEnabledForThisHeading := .Attributes.anchor | default true -}}
|
|
{{- $hasAnchor := and $pageWantsAnchors $anchorEnabledForThisHeading -}}
|
|
<h{{ .Level }} id="{{ .Anchor }}" class="heading{{ if $hasAnchor }} with-anchor{{ end }}">
|
|
{{- if $hasAnchor -}}
|
|
<span class="heading__anchor">
|
|
<a href="#{{ .Anchor }}">{{ range seq .Level }}#{{ end }}</a>
|
|
</span>
|
|
{{- end -}}
|
|
{{ .Text | safeHTML }}
|
|
</h{{ .Level }}>
|