docs-v2/layouts/shortcodes/children.html

67 lines
2.2 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 }}
2020-03-11 17:21:49 +00:00
{{ $title := cond ( isset .Params "list_title" ) .Params.list_title .Title }}
{{ $url := cond ( isset .Params "external_url" ) .Params.external_url .RelPermalink }}
{{ $target := cond ( isset .Params "external_url" ) "_blank" "" }}
<h3 id="{{ anchorize $title }}"><a href="{{ $url }}" target="{{ $target }}">{{ $title }}</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 }}
{{ if .Params.list_code_example }}
{{ .Params.list_code_example | markdownify }}
{{ end }}
{{ end }}
{{ else if (eq $type "functions") }}
<ul>
{{ range $pages.ByWeight }}
2019-02-11 21:26:13 +00:00
{{ $title := replaceRE `\ function` "" .Title }}
<li><a href="{{ .RelPermalink }}">{{ if .Params.list_title }}{{ .Params.list_title }}{{ else }}{{ $title }}{{ end }}</a></li>
{{ end }}
<ul>
{{ else if (eq $type "list") }}
<ul>
{{ range $pages.ByWeight }}
{{ $title := cond ( isset .Params "list_title" ) .Params.list_title .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>") "" }}
2020-03-11 17:21:49 +00:00
<li><a href="{{ $url }}" target="{{ $target }}">{{ $title }}</a> {{ $note | markdownify }}</li>
{{ end }}
<ul>
{{ end }}
</div>