{{/* Page layout used for art details view, when visiting a specific artwork. */}}

{{ define "main" }}
    <h2>{{ .Title }}</h2>
    <i style="margin: 0">
    Posted on
    <time datetime="{{ .Page.Lastmod.Format "2006-01-02" }}" class="text-muted">
        {{ $.Date.Format "January 2006" }}
    </time>
    </i>

    {{ if  (and (not $.Params.animation) (and (not (in .File.Dir "art/guest")) (and (not $.Params.threed) (not $.Params.comic) )) ) }}
        {{ $full := printf "%s/art/%s.avif" $.Site.Params.image_host $.Params.filename }}
        {{ $jpeg := printf "%s/art/%s.jpg" $.Site.Params.image_host $.Params.filename }}

        <picture>
                <source srcset="{{ $full }}" type="image/avif" width="{{ $.Params.width }}" height="{{ $.Params.height }}"/>
                <img class="gallery-img" style="display: block; max-height: 1000px; margin-left: auto; margin-right: auto; width: auto; margin-top: 10px; margin-bottom: 10px; max-width: 100%; height: auto" alt="{{ $.Params.alt_text }}" width="{{ $.Params.width }}" height="{{ $.Params.height }}" src="{{ $jpeg }}"/>
        </picture>
    {{ else }}

        {{ if $.Params.threed }}
            {{ $file := printf "%s/3d/%s.glb" $.Site.Params.image_host $.Params.slug }}
            {{ with $file }}
                {{ $cameraorbit := $.Params.orbit }}
                {{ $cameratarget := $.Params.target }}
                {{ $fov  := $.Params.fov }}
                <model-viewer style="margin-top: 10px; margin-bottom: 10px;" class="gallery-img" alt="{{ $.Params.alt_text }}" title="{{ $.Params.alt_text }}" src="{{ . }}" shadow-intensity="1" camera-controls touch-action="pan-y" camera-orbit="{{ $cameraorbit }}" camera-target="{{ $cameratarget }}" field-of-view="{{ $fov }}"></model-viewer>
            {{ end }}
        {{ else }}
            {{ $file := printf "%s/animation/%s.webm" $.Site.Params.image_host $.Params.slug }}
            {{ with $file }}
                {{ if $.Params.animation }}
                    <div style="text-align: center;">
                        <video style="max-width: 100%" class="gallery-img" controls loop>
                            <source src="{{ . }}" type="video/webm">
                        </video>
                    </div>
                {{ end }}
            {{ end }}
        {{ end }}
    {{ end }}

    {{ if $.Params.comic }}
        {{ range $.Params.pages }}
            {{ $full := printf "%s/art/%s.avif" $.Site.Params.image_host .filename }}
            {{ $jpeg := printf "%s/art/%s.jpg" $.Site.Params.image_host .filename}}

            <picture>
                    <source srcset="{{ $full }}" type="image/avif"/>
                    <img class="gallery-img" style="display: block; max-height: 1000px; margin-left: auto; margin-right: auto; width: auto; margin-top: 10px; margin-bottom: 10px; max-width: 100%; height: auto" alt="{{ .alt_text }}" src="{{ $jpeg }}"/>
            </picture>
        {{ end }}
    {{ end }}

    {{ partial "voting" . }}

    <div class="generic-con" id="art-detail-inline">
    {{ partial "art-detail" . }}

    {{ with .Content }}
        {{ $.Scratch.Set "header-type" "h3" }}
        {{ $.Scratch.Set "header-name" "Commentary" }}
        {{ partial "fake-heading.html" $ }}

        {{ . }}
    {{ end }}
    </div>

    {{ if .Params.threed }}
        {{ $site := resources.Get "js/model-viewer.min.js" }}
        {{ if hugo.IsProduction }}
            {{ $site = $site | fingerprint | resources.PostProcess }}
        {{ end }}
        <script type="module" src="{{ $site.RelPermalink }}" integrity="{{ $site.Data.Integrity }}"></script>
    {{ end }}

    {{ partial "comments" . }}
{{ end }}

{{ define "details" }}
    {{ partial "art-sidebar" . }}

    <hr>

    {{ partial "art-detail" . }}
{{ end }}
