docs-v2/layouts/shortcodes/children.html

53 lines
1.7 KiB
HTML
Raw Normal View History

{{ $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") }}
2020-03-04 16:11:00 +00:00
{{ .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 }}
2019-02-11 21:26:13 +00:00
{{ $title := replaceRE `\ function` "" .Title }}
{{ $url := cond ( isset .Params "external_url" ) .Params.external_url .RelPermalink }}
{{ $target := cond ( isset .Params "external_url" ) "_blank" "" }}
{{ $note := cond ( isset .Params "list_note" ) (print "<span class='list-note'>" .Params.list_note "</span>") "" }}
<li><a href="{{ $url }}" target="{{ $target }}">{{ if .Params.list_title }}{{ .Params.list_title }}{{ else }}{{ $title }}{{ end }}</a> {{ $note | markdownify }}</span></li>
{{ end }}
<ul>
{{ end }}
</div>