{{ define "title" }}
    <h1>{{ if .Title }}{{ .Title }}{{ else }}{{ if i18n .Section }}{{ i18n .Section }}{{ else }}{{ .Section }}{{ end }}{{ end }}</h1>
{{ end }}

{{ define "content" }}
    {{ partial "debug" (dict "context" . "caller" "list.html")}}
    {{- $pages := where .Site.RegularPages "Permalink" "!=" .Permalink -}}
    {{ $partial := "" }}
    {{ $title := "" }}
    {{ $pic := "true" }}
    {{ $pre := "l1" }}
    {{- $paginator := "" -}}
    {{ $part := .Layout }}
    {{ $partial_before := "" }}
    {{ $paginate := false }}
    {{ if eq .Layout "article_list" }}
        {{ $paginate = true }}
        {{ if eq .Section "events" }}
            {{- $pages = where $pages ".Params.when" "ne" nil -}}
        {{ else if eq .Type "about" }}
            {{- $pages = where $pages ".Params.about" "=" true -}}
        {{ else if eq .Section "news" }}
            {{- $pages = .Data.Pages -}}
        {{ else if eq .Section "featured" }}
            {{- $pages = where $pages ".Params.featured" "=" true -}}
        {{ end }}
    {{ else if or (eq .Layout "contact") (eq .Layout "imprint") }}
         {{ $partial_before = "snippets/contact" }}
    {{ else }}
        {{ if eq .Kind "term" }}
            {{- $pages = .Data.Pages -}}
            {{ $part = "article_list" }}
        {{ else if or (eq .Kind "taxonomy") }}
            {{- $pages = .Data.Terms.Alphabetical -}}
            {{ $part = "tags_n_categories" }}
        {{ end }}    
    {{ end }}
    {{ if eq $paginate true}}
        {{- $paginator = .Paginate $pages -}}
    {{ end }}
    {{ if and $pre $part }}
        {{ $partial := string (printf "%s/%s" $pre $part) }}
        {{ partial $partial (dict "context" . "paginator" $paginator "pages" $pages "amount" "5" "title" $title "content" .Content "pic" $pic "type" .Type "partial_before" $partial_before "paginate" $paginate) }}
    {{ end }}
{{ end }}
