1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-09-20 04:12:09 +00:00
seirdy.one/layouts/_default/_markup/render-heading.html
Rohan Kumar 809fed4308
Accessible in-page heading anchors!
Bit the bullet and decided to make anchors that look great to
terminal/textual browsers, ARIA + screen reader combos, and a regular
browser.
2022-05-19 13:26:54 -07:00

11 lines
493 B
HTML

{{- if and (eq .Level 2) (eq .Page.Section "posts") }}
<h{{ .Level }} id="{{ .Anchor | safeURL }}-hd">{{ .Text | safeHTML -}}</h{{ .Level }}>
<a
id="{{ .Anchor | safeURL }}" href="#{{ .Anchor | safeURL }}"
aria-labelledby="{{ .Anchor | safeURL }}-prefix {{ .Anchor | safeURL }}-hd">
<span id="{{ .Anchor | safeURL }}-prefix">Permalink to section</span>
</a>
{{- else }}
{{- with . -}}
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML -}}</h{{ .Level }}>{{ end -}}
{{- end }}