<div class="content">
  <table class="table is-striped is-hoverable is-bordered">
    {{ if isset .Params "infos" }}
      {{ if gt (len .Params.infos) 1 }}
        <thead>
          <tr>
            {{ range .Params.infos }}
              <th>{{ title .name }}</th>
            {{ end }}
          </tr>
        </thead>
      {{ end }}
    {{ end }}
    <tbody>
      {{ range $page := (.Paginator 15).Pages }}
        <tr>
          {{ range $info := $.Params.infos }}
            {{ $key := "" }}
            {{ if eq (index $info "key") nil }}
              {{ $key = $info.name }}
            {{ else }}
              {{ $key = $info.key }}
            {{ end }}

            {{ $value := (index $page.Params $key) }}

            {{ $type := "" }}
            {{ if ne (index $info "type") nil }}
              {{ $type = $info.type }}
            {{ end }}

            {{ $link := false }}
            {{ $linktarget := "" }}

            {{/* get default link */}}
            {{ if ne (index $info "defaultlink") nil }}
              {{ $link = $info.defaultlink }}
            {{ end }}

            {{/* look for overwrites */}}
            {{ if ne (index $page.Params "links") nil }}
              {{ if ne (index $page.Params.links $key) nil }}
                {{ $link = default $link (index (index $page.Params.links $key) "enable") }}
              {{ end }}
            {{ end }}

            {{/* get the link target */}}
            {{ if ne (index $page.Params "links") nil }}
              {{ if ne (index $page.Params.links $key) nil }}
                {{ $linktarget = default "" (index (index $page.Params.links $key) "target") }}
              {{ end }}
            {{ end }}

            {{/* fall back to default target if none given */}}
            {{ if and ($link) (eq $linktarget "") }}
              {{ $linktarget = $page.Permalink }}
            {{ end }}

            {{ $externallink := "" }}
            {{ if ne (index $page.Params "externallink") nil }}
              {{ $externallink = (index $page.Params "externallink") }}
            {{ else if ne (index $info "externallink") nil }}
              {{ $externallink = (index $info "externallink") }}
            {{ end }}

            {{ $datespan := false }}
            {{ $dateto := "" }}

            {{ if (eq $type "date") }}
              {{ if ne (index $page.Params "dateto") nil }}
                {{ $datespan = true }}
                {{ $dateto = (index $page.Params "dateto") }}
              {{ end }}
              <td>
                <time class="list-time" datetime="{{- dateFormat "2006-01-02" $value -}}">
                  {{- dateFormat "2006-01-02" $value -}}
                </time>
                {{- if $datespan -}}
                <br>
                <time class="dateto" datetime="{{ dateFormat "2006-01-02" $dateto -}}">
                  &ndash;
                  {{ dateFormat "2006-01-02" $dateto -}}
                </time>
                {{ end }}
              </td>
            {{ else }}
              <td>
                {{ if (eq $link true) }}
                <a href="{{ $linktarget }}">
                  {{ $value }}
                </a>
                {{ else }}
                  {{ $value }}
                {{ end }}
              </td>
            {{ end }}
          {{ end }}
        </tr>
      {{ end }}
    </tbody>
  </table>
</div>
{{ partial "pagination.html" . }}
