{{ define "main" }}
    {{ $paginator := .Paginate .Data.Pages }}
    
    <main class="posts instagram">
        <h1>{{ title (replace .Title "-" " ") }}</h1>

        {{ if .Content }}
            <div class="content">{{ .Content }}</div>
        {{ end }}

        {{ range $paginator.Pages.GroupByDate "2006" }}
            <div class="posts-group">
                <div class="post-year">{{ .Key }}</div>

                <ul class="posts-list">
                    {{ range .Pages }}
                        <li class="post-item">
                            <a href="{{.Permalink}}">
                              {{ $firstMedia := index .Params.Media 0 }}
                              <img src="{{.Permalink}}{{ $firstMedia }}{{if hasSuffix $firstMedia ".mp4"}}.jpg{{ end }}" />
                            </a>
                        </li>
                    {{ end }}
                </ul>
            </div>
        {{ end }}
    {{ partial "pagination-list.html" . }}
    </main>
{{ end }}
