From dee99c36a6fd7615d775c365774cc9b2547a5a97 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Mon, 4 Dec 2023 14:29:41 -0800 Subject: [PATCH] Defend against missing aliases in quick-reference shortcode --- layouts/shortcodes/quick-reference.html | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 layouts/shortcodes/quick-reference.html diff --git a/layouts/shortcodes/quick-reference.html b/layouts/shortcodes/quick-reference.html new file mode 100644 index 000000000..95044f934 --- /dev/null +++ b/layouts/shortcodes/quick-reference.html @@ -0,0 +1,39 @@ +{{/* +Renders the child sections of the given top-level section, listing each childs's immediate descendants. + +@param {string} section The top-level section to render. +@returns template.HTML + +@example {{% quick-reference section="functions" %}} +*/}} + +{{ $section := "" }} +{{ with .Get "section" }} + {{ $section = . }} +{{ else }} + {{ errorf "The %q shortcodes requires a 'section' parameter. See %s" .Name .Postion }} +{{ end }} + +{{/* Do not change the markdown indentation, and do not remove blank lines. */}} +{{ with site.GetPage $section }} + {{ range .Sections }} + +## {{ .LinkTitle }} +{{ .RawContent }} + + {{ range .Pages }} + {{ $aliases := "" }} + {{ if eq .Section "functions" }} + {{ with .Params.action.aliases }} + {{ $aliases = delimit . " or " }} + {{ end }} + {{ end }} + +[{{ .LinkTitle }}]({{ .RelPermalink }}) {{ with $aliases }}({{ . }}){{ end }} +: {{ .Description }} + + {{ end }} + {{ end }} +{{ else }} + {{ errorf "The %q shortcodes was unable to find the %q section. See %s" .Name $section .Postion }} +{{ end }}