{{/* Page layout used for blog list view and others. */}}

{{ define "main" }}
    <h2>{{ .Title }}</h2>

    <hr>

    {{ $paginator := .Paginate .Pages }}

    {{ if eq $paginator.PageNumber 1}}
    {{ .Content }}
    {{ end }}

    <table>
        <tr>
            <th>Title</th>
            <th>Summary</th>
            <th>Date</th>
        </tr>

        {{ range $paginator.Pages }}
            <tr>
                <td><a href="{{ .RelPermalink }}">{{ .Title }}</a></td>

                <td>
                    {{ .Summary }}
                </td>

                <td>
                    <time datetime='{{ .Date.Format "2006-01-02" }}'>{{ .Date.Format "Jan 2, 2006"}}</time>
                </td>
            </tr>
        {{ end }}
    </table>

    <div style="text-align: center; margin-top: 10px;">
    {{ with $paginator.Prev }}
    <a style="float: left" href="{{ .URL }}">Prev</a>
    {{ else }}
    <span style="float: left">Prev</span>
    {{ end }}

    <span style="display: inline-block;">{{ printf "Page %d" $paginator.PageNumber }}</span>

    {{ with $paginator.Next }}
    <a style="float: right" href="{{ .URL }}">Next</a>
    {{ else }}
    <span style="float: right">Next</span>
    {{ end }}

    </div>
{{ end }}
