main
html 27 lines 906 Bytes
Raw
1 {{- $page := . -}}
2 {{- $sections := slice
3 (dict "id" "this-weeks-trends" "label" "Trends")
4 (dict "id" "where-industry-meets-code" "label" "Industry")
5 (dict "id" "signal-noise" "label" "Signal")
6 (dict "id" "blind-spots" "label" "Blind Spots")
7 (dict "id" "the-week-ahead" "label" "Week Ahead")
8 (dict "id" "key-references" "label" "References")
9 -}}
10 {{- $links := slice -}}
11 {{- range $sections -}}
12 {{- $quotedID := printf "id=\"%s\"" .id -}}
13 {{- $bareID := printf "id=%s" .id -}}
14 {{- if or (in $page.Content $quotedID) (in $page.Content $bareID) -}}
15 {{- $links = $links | append . -}}
16 {{- end -}}
17 {{- end -}}
18 {{- if gt (len $links) 0 -}}
19 <nav class="article-jump-nav" aria-label="Jump to article sections">
20 <span class="article-jump-nav__label">Jump to</span>
21 <ul>
22 {{- range $links }}
23 <li><a href="#{{ .id }}">{{ .label }}</a></li>
24 {{- end }}
25 </ul>
26 </nav>
27 {{- end -}}