mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-16 10:14:44 -04:00
Defend against missing aliases in quick-reference shortcode
This commit is contained in:
parent
d305278f18
commit
dee99c36a6
39
layouts/shortcodes/quick-reference.html
Normal file
39
layouts/shortcodes/quick-reference.html
Normal 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 }}
|
Loading…
x
Reference in New Issue
Block a user