{{ define "header" }}
  {{ partial "masthead.html" . }}
{{ end }}
{{ define "main" }}
  <article itemscope itemtype="https://schema.org/BlogPosting">
    {{ template "_internal/schema.html" . }}
    <header>
      <h1 itemprop="headline name">{{ .Title }}</h1>
      <p class="muted">
        {{ partial "post/meta.html" . }}
      </p>
      {{ if .Description }}
        <blockquote itemprop="description">{{ .Description }}</blockquote>
      {{ end }}
      {{ with $.Resources.GetMatch "header" }}
        {{ $meta_sameas := .Params.meta.sameas }}
        {{ $meta_license := .Params.meta.license }}
        {{ $meta_creator := .Params.meta.creator }}
        {{ $meta_description := .Params.meta.description }}
        {{ $meta_keywords := .Params.meta.keywords }}
        {{ $meta_contentlocation := .Params.meta.contentlocation }}
        {{ $image600 := .Fill "600x338 q60 Center" }}
        {{ $image900 := .Fill "900x506 q70 Center" }}
        {{ $image1200 := .Fill "1200x675 q80 Center" }}
        {{ $image1600 := .Fill "1600x900 q90 Center" }}
        <figure aria-hidden="true" itemscope itemtype="https://schema.org/ImageObject">
          <link itemprop="contentUrl" href="{{ .RelPermalink }}">
          <meta itemprop="encodingFormat" content="{{ .MediaType }}">
          <meta itemprop="name" content="{{ .Name | plainify }}">
          {{ if (urls.Parse $meta_sameas).Host }}
            <link itemprop="sameAs" href="{{ $meta_sameas }}">
          {{ end }}
          {{ if (urls.Parse $meta_license).Host }}
            <link itemprop="license" href="{{ $meta_license }}">
          {{ end }}
          {{ with $meta_keywords }}
            <meta itemprop="keywords" content="{{ delimit . ", " }}">
          {{ end }}
          {{ with $meta_contentlocation }}
            <meta itemprop="contentLocation" content="{{ . | plainify }}">
          {{ end }}
          {{ with $meta_description }}
            <meta itemprop="description" content="{{ . | plainify }}">
          {{ end }}
          <img
            itemprop="thumbnailUrl"
            alt="{{ with $meta_description }}{{ . }}{{ else }}{{ .Name | plainify }}{{ end }}"
            class="lazyload blur-up"
            src="{{ $image600.RelPermalink }}"
            data-sizes="auto"
            data-src="{{ $image1200.RelPermalink }}"
            data-srcset="{{ $image600.RelPermalink }} 600w, {{ $image900.RelPermalink }} 900w, {{ $image1200.RelPermalink }} 1200w, {{ $image1600.RelPermalink }} 1600w"
          >
          {{ if or (not (path.Ext .Title)) (or $meta_creator $meta_sameas) }}
            <style>
              .hack header figure[itemtype*="ImageObject"] {
                position: relative;
              }
              .hack header figure[itemtype*="ImageObject"] figcaption {
                position: absolute;
                bottom: 0;
                right: 0;
                text-align: right;
                padding: 15px;
                font-style: oblique;
                font-size: smaller;
                mix-blend-mode: soft-light;
              }
              .hack header figure[itemtype*="ImageObject"] [itemprop="headline"] {
                font-weight: bold;
              }
            </style>
            <figcaption itemprop="caption">
              {{ if not (path.Ext .Title) }}
                <span itemprop="headline">{{ .Title | plainify }}</span>.
              {{ end }}
              {{ if or $meta_creator $meta_sameas }}
                Photo
                {{ if $meta_creator }}
                  by
                  <span itemprop="creator">
                    {{ $meta_creator | plainify -}}
                  </span>
                {{- end }}
                {{- with (urls.Parse $meta_sameas).Host }}
                  on
                  {{ (strings.TrimSuffix (path.Ext .) .) | title }}
                {{- end }}.
              {{ end }}
            </figcaption>
          {{ end }}
        </figure>
      {{ end }}
    </header>
    {{ partial "toc-maybe.html" . }}
    <div itemprop="articleBody">
      {{ .Content }}
    </div>
    <footer>
      <hr>
      {{ partial "post/byline.html" . }}
      {{ partial "post/related-content.html" . }}
      {{ template "_internal/disqus.html" . }}
    </footer>
  </article>
{{ end }}
{{ define "footer" }}
  {{ partial "powered-by.html" . }}
  {{ partial "cookie-disclaimer.html" . }}
{{ end }}
