glossary.html - hugo - [fork] hugo port for 9front
HTML git clone https://git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
glossary.html (1821B)
---
1 {{- /*
2 Renders the glossary of terms.
3
4 When you call this shortcode using the {{% %}} notation, the glossary terms are
5 Markdown headings (level 6) which means they are members of .Fragments. This
6 allows the link render hook to verify links to glossary terms.
7
8 Yes, the terms themselves are pages, but we don't want to link to the pages, at
9 least not right now. Instead, we want to link to the ids rendered by this
10 shortcode.
11
12 @example {{% glossary %}}
13 */ -}}
14 {{- $path := "/quick-reference/glossary" }}
15 {{- with site.GetPage $path }}
16
17 {{- /* Build and render alphabetical index. */}}
18 {{- $m := dict }}
19 {{- range $p := .Pages.ByTitle }}
20 {{- $k := substr .Title 0 1 | strings.ToUpper }}
21 {{- if index $m $k }}
22 {{- continue }}
23 {{- end }}
24 {{- $anchor := path.BaseName .Path | anchorize }}
25 {{- $m = merge $m (dict $k $anchor) }}
26 {{- end }}
27 {{- range $k, $v := $m }}
28 [{{ $k }}](#{{ $v }}) {{/* Do not indent. */}}
29 {{- end }}
30
31 {{/* Render glossary terms. */}}
32 {{- range $p := .Pages.ByTitle }}
33 {{ .Title }}{{/* Do not indent. */}}
34 : {{ .RawContent | strings.TrimSpace | safeHTML }}{{/* Do not indent. */}}
35 {{ with .Params.reference }}
36 {{- $destination := "" }}
37 {{- with $u := urls.Parse . }}
38 {{- if $u.IsAbs }}
39 {{- $destination = $u.String }}
40 {{- else }}
41 {{- with site.GetPage $u.Path }}
42 {{- $destination = .RelPermalink }}
43 {{- else }}
44 {{- errorf "The %q shortcode was unable to find the reference link %s: see %s" $.Name . $p.String }}
45 {{- end }}
46 {{- end }}
47 {{- end }}
48 : See [details]({{ $destination }}).{{/* Do not indent. */}}
49 {{- end }}
50 {{ end }}
51
52 {{- else }}
53 {{- errorf "The %q shortcode was unable to get %s: see %s" .Name $path .Position}}
54 {{- end }}