{{ define "title" }}Search Results: {{.V.search}}{{ end }}
{{ define "content" }}

<div class="card">
	<div class="card-body">
		<h1>Search Results</h1>

        {{ $Pager := .V.posts }}

		<p>
            <em>{{ $Pager.Total}} results found for:</em> {{.V.search}}
        </p>

        <div class="row">
            <div class="col-12 col-md-8">
                <span class="tag is-secondary" title="{{ $Pager.Total }} total posts">
                    Page {{ $Pager.Page }} of {{ $Pager.Pages }}
                </span>
            </div>
        
            <div class="col-12 col-md-4">
                {{ if $Pager.PreviousPage }}
                    <a href="?q={{ .V.search }}&page={{ $Pager.PreviousPage }}" class="button has-text-dark is-small is-light">Previous</a>
                {{ end }}
                {{ if $Pager.NextPage }}
                    <a href="?q={{ .V.search }}&page={{ $Pager.NextPage }}" class="button has-text-dark is-small is-primary">Next page</a>
                {{ end }}
            </div>
        </div>

        <div class="columns is-multiline">
        {{ range .V.posts.Posts }}
            <div class="column is-one-quarter mb-4">
                <div class="card" title="{{ .Title }}">
                    <div class="card-image">
                        <figure class="image is-4by3">
                            {{ if .Thumbnail }}
                                <a href="/{{ .Fragment }}">
                                    <img src="/static.thumb{{ .Thumbnail }}"
                                        style="object-fit: cover"
                                        loading="lazy">
                                </a>
                            {{ else }}
                                <div class="has-text-centered is-size-1 pt-6">
                                    <i class="fa fa-blog"></i>
                                </div>
                            {{ end }}
                        </figure>
                    </div>
                    <div class="card-content py-3 px-4">
                        <a href="/{{ .Fragment }}">{{ .Title }}</a><br>
                        <small class="blog-meta">
                            {{ .CreatedAt.Format "Jan 02 2006" }}
                            {{ if ne .Privacy "public" }}
                                <span class="blog-{{ .Privacy }}">[{{ .Privacy }}]</span>
                            {{ end }}
                        </small>
                    </div>
                </div>
            </div>
        {{ end }}
        </div>

        <div class="columns">
            <div class="column">
                <span class="tag is-secondary" title="{{ $Pager.Total }} total posts">
                    Page {{ $Pager.Page }} of {{ $Pager.Pages }}
                </span>
            </div>
        
            <div class="column is-narrow">
                {{ if $Pager.PreviousPage }}
                    <a href="?q={{ .V.search }}&page={{ $Pager.PreviousPage }}" class="button has-text-dark is-small is-light">Previous</a>
                {{ end }}
                {{ if $Pager.NextPage }}
                    <a href="?q={{ .V.search }}&page={{ $Pager.NextPage }}" class="button has-text-dark is-small is-primary">Next page</a>
                {{ end }}
            </div>
        </div>

	</div>
</div>

{{ end }}
