Merge commit '346b60358dd8ec2ca228e6635bff9d7914b398b7'

This commit is contained in:
Bjørn Erik Pedersen
2025-01-23 09:47:46 +01:00
384 changed files with 3305 additions and 3271 deletions

View File

@@ -0,0 +1,20 @@
{{- /*
Renders the definition of the given glossary term.
@param {string} (.Get 0) The glossary term.
@returns {template.HTML}
@example {{% glossary-term float %}}
@example {{% glossary-term "floating point" %}}
*/}}
{{- with .Get 0 }}
{{- $path := printf "/getting-started/glossary/%s" (urlize .) }}
{{- with site.GetPage $path }}
{{ .RenderShortcodes }}{{/* Do not indent. */}}
{{- else }}
{{- errorf "The glossary term (%s) shortcode was unable to find %s: see %s" $.Name $path $.Position }}
{{- end }}
{{- else }}
{{- errorf "The glossary term (%s) shortcode requires one positional parameter: see %s" $.Name $.Position }}
{{- end }}

View File

@@ -0,0 +1,43 @@
{{- /*
Renders the glossary of terms.
When you call this shortcode using the {{% %}} notation, the glossary terms are
Markdown headings (level 6) which means they are members of .Page.Fragments.
This allows the link render hook to verify links to glossary terms.
Yes, the terms themselves are pages, but we don't want to link to the pages, at
least not right now. Instead, we want to link to the fragments rendered by this
shortcode.
@returns {template.HTML}
@example {{% glossary %}}
*/}}
{{- $path := "/getting-started/glossary" }}
{{- with site.GetPage $path }}
{{- with $p := .Pages.ByTitle }}
{{- /* Build and render alphabetical index. */}}
{{- $m := dict }}
{{- range $p }}
{{- $k := substr .Title 0 1 | strings.ToUpper }}
{{- if index $m $k }}
{{- continue }}
{{- end }}
{{- $anchor := path.BaseName .Path | anchorize }}
{{- $m = merge $m (dict $k $anchor) }}
{{- end }}
{{- range $k, $v := $m }}
[{{ $k }}](#{{ $v }}) {{/* Do not indent. */}}
{{- end }}
{{- /* Render glossary terms. */}}
{{- range $p }}
###### {{ .Title }}{{/* Do not indent. */}}
{{ .RenderShortcodes }}{{/* Do not indent. */}}
{{- end }}
{{- end }}
{{- else }}
{{- errorf "The %q shortcode was unable to get %s: see %s" .Name $path .Position}}
{{- end }}