Defend against missing aliases in quick-reference shortcode

This commit is contained in:
Joe Mooring 2023-12-04 14:29:41 -08:00 committed by Joe Mooring
parent d305278f18
commit dee99c36a6

View File

@ -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 }}