{{ $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.Pages }}
{{ 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>
	{{ 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>
