mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-12-27 10:52:09 +00:00
c26a6d6cc8
- Don't auto-minify HTML but minify other resources, inc. the RSS feed - Manually optimize whitespace a little to balance readability and compressed size
29 lines
1.3 KiB
HTML
29 lines
1.3 KiB
HTML
<!--
|
|
For now, make the anchor link invisible to screen readers.
|
|
1. The anchor would need an accessible name, but aria-labels don't
|
|
translate well with machine translation. It would need to be
|
|
labelledby another element hidden by CSS, which would crowd the
|
|
page for non-CSS users.
|
|
2. Screen reader users don't depend on visually identifying heading
|
|
levels and can easily jump between headings without scrolling to
|
|
the table of contents, so these anchor links are slightly less
|
|
useful to them.
|
|
3. These links don't expose new functionality, since users could
|
|
already copy heading anchor links in the TOC. This just makes some
|
|
existing functionality slightly more easily. So it's less of a big
|
|
deal
|
|
4. This reliably hides them from certain reading-mode implementations
|
|
(e.g. Readability)
|
|
Yeah I know, the situation isn't optimal.
|
|
-->{{- with . -}}
|
|
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML -}}
|
|
{{- if and (gt .Level 1) (eq .Page.Section "posts") -}}
|
|
<span aria-hidden="true"> <!--Wrap in a span so the whitespace before the link is also hidden-->
|
|
<a href="#{{ .Anchor | safeURL }}" tabindex="-1">
|
|
{{- $octothorpes := sub .Level 1 -}}
|
|
{{- range $i, $sequence := (seq $octothorpes) -}}
|
|
{{- print `#` -}}
|
|
{{- end -}}
|
|
</a></span>
|
|
{{- end }}
|
|
</h{{ .Level }}>{{ end }}
|