1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-24 13:12:10 +00:00
seirdy.one/layouts/shortcodes/codecaption.html
Rohan Kumar f798de7e63
A11y: drop draft ARIA, overhaul in-page links
- Stop using draft WAI-ARIA 1.3 that isn't supported yet
- Make in-page links focusable across shortcodes/partials
- Replace existing in-page heading anchor links with a more accessible
  option.
- Make backlinks aria-labelledby instead of giving them an aria-label,
  so they can be translated.
2022-05-19 17:18:14 -07:00

17 lines
617 B
HTML

{{- $codeIndex := (.Page.Scratch.Get "codeIndex") -}}
{{- $id := (printf `code-%d` $codeIndex) -}}
{{- with .Get "id" -}}
{{- $id = . -}}
{{- end -}}
{{ with .Parent }}
{{- with .Get "id" -}}
{{- $id = . -}}
{{- end -}}
{{- end -}}
<figcaption id="{{ $id }}-caption">
<span id="{{ $id }}" tabindex="-1">
<strong itemprop="name"> <span itemprop="codeSampleType">Code snippet</span> {{ $codeIndex }}</strong>{{with .Get "lang"}} (<span itemprop="programmingLanguage">{{ . }}</span>){{ end -}}
</span>:
{{ .Inner | markdownify | safeHTML }}
</figcaption>
{{- .Page.Scratch.Set "codeIndex" (add 1 $codeIndex) -}}