docs-v2/layouts/shortcodes/children.html

50 lines
1.4 KiB
HTML

{{ $type := .Get "type" | default "articles" }}
{{ $show := .Get "show" | default "all" }}
{{ if eq $show "all" }}
{{ .Scratch.Set "pages" (union .Page.Pages .Page.Sections) }}
{{ else if (eq $show "sections") }}
{{ .Scratch.Set "pages" .Page.Sections }}
{{ else if (eq $show "pages") }}
{{ .Scratch.Set "pages" .Page.RegularPages }}
{{ end }}
{{ $pages := .Scratch.Get "pages" }}
<div class="children-links">
{{ if eq $type "articles" }}
{{ range $pages.ByWeight }}
<h3><a href="{{ .RelPermalink }}" >{{ if .Params.list_title }}{{ .Params.list_title }}{{ else }}{{ .Title }}{{ end }}</a></h3>
<p>
{{- if .Description }}{{- .Description | markdownify -}}
{{ else }}{{- .Summary | markdownify -}}
{{ end -}}
</p>
{{ if .Params.list_image }}
{{ $img := .Params.list_image }}
{{ if (fileExists ( print "/static" $img )) }}
{{ with (imageConfig ( print "/static" $img )) }}
{{ $imageWidth := div .Width 3 }}
<img src='{{ $img }}' width='{{ $imageWidth }}' />
{{ end }}
{{ else }}
<img src='{{ $img }}'/>
{{ end }}
{{ end }}
{{ end }}
{{ else if (eq $type "functions") }}
<ul>
{{ range $pages.ByWeight }}
{{ $title := replaceRE `\ function` "" .Title }}
<li><a href="{{ .RelPermalink }}">{{ if .Params.list_title }}{{ .Params.list_title }}{{ else }}{{ $title }}{{ end }}</a></li>
{{ end }}
<ul>
{{ end }}
</div>