{{ $disableImageOptimization := .Site.Params.disableImageOptimization | default false }}
{{ $disableHeroImageFilter := .Site.Params.homepage.disableHeroImageFilter | default false }}
<article class="max-w-full prose dark:prose-invert">
  <div class="relative">
    <div class="absolute inset-x-0 bottom-0 h-1/2"></div>
    <div class="mx-auto max-w-7xl p-0">
      <div class="relative shadow-xl sm:overflow-hidden rounded-2xl">
        <div class="absolute inset-0">
          {{ $useDefault := true }}
          {{ $homepageImage := "" }}
          {{ with .Site.Params.defaultBackgroundImage }}
            {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
              {{ $homepageImage = resources.GetRemote . }}
            {{ else }}
              {{ $homepageImage = resources.Get . }}
            {{ end }}
          {{ end }}
          {{ with .Site.Params.homepage.homepageImage }}
            {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
              {{ $homepageImage = resources.GetRemote . }}
              {{ $useDefault = false }}
            {{ else }}
              {{ $homepageImage = resources.Get . }}
              {{ $useDefault = false }}
            {{ end }}
          {{ end }}
          {{ if $homepageImage }}
            {{ $style := "" }}
            {{ $defaultPosition := cond $useDefault site.Params.imagePosition false }}
            {{ with $.Params.imagePosition | default $defaultPosition }}
              {{ $style = printf "object-position: %s;" . }}
            {{ end }}
            <img
              class="h-full w-full object-cover nozoom mt-0 mr-0 mb-0 ml-0"
              src="{{ $homepageImage.RelPermalink }}"
              {{ if $style }}style="{{ $style | safeCSS }}"{{ end }}>
            {{ if not $disableHeroImageFilter }}
              <div
                class="absolute inset-0 bg-gradient-to-r from-primary-500 to-secondary-600 dark:from-primary-600 dark:to-secondary-800 mix-blend-multiply"></div>
            {{ else }}
              <div
                class="absolute inset-0 from-primary-500 to-secondary-600 dark:from-primary-600 dark:to-secondary-800 mix-blend-multiply"></div>
            {{ end }}
          {{ end }}
        </div>
        <div
          class="relative px-4 py-16 sm:px-6 sm:py-24 lg:py-32 lg:px-8 flex flex-col items-center justify-center text-center">
          {{ with .Site.Params.Author.image }}
            {{ $authorImage := "" }}
            {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
              {{ $authorImage = resources.GetRemote . }}
            {{ else }}
              {{ $authorImage = resources.Get . }}
            {{ end }}
            {{ if $authorImage }}
              {{ $final := $authorImage }}
              {{ $squareImage := $authorImage }}
              {{ if not (or $disableImageOptimization (eq $authorImage.MediaType.SubType "svg")) }}
                {{ $final = $authorImage.Fill (print "288x288 q" ( $.Site.Params.Author.imagequality | default "96" )) }}
                {{ $shortSide := int (math.Min $authorImage.Width $authorImage.Height) }}
                {{ $squareImage = $authorImage.Crop (printf "%dx%d" $shortSide $shortSide ) }}
              {{ end }}
              <img
                class="mb-2 h-36 w-36 rounded-full"
                width="144"
                height="144"
                alt="{{ $.Site.Params.Author.name | default `Author` }}"
                src="{{ $final.RelPermalink }}"
                data-zoom-src="{{ $squareImage.RelPermalink }}">
            {{ end }}
          {{ end }}
          {{ if not $disableHeroImageFilter }}
            <h1 class="mb-2 text-4xl font-extrabold text-neutral-200">
              {{ .Site.Params.Author.name | default .Site.Title }}
            </h1>
            {{ with .Site.Params.Author.headline }}
              <h2 class="mt-0 mb-0 text-xl text-neutral-300">
                {{ . | markdownify }}
              </h2>
            {{ end }}
          {{ else }}
            <h1 class="mb-2 text-4xl font-extrabold text-neutral-800 dark:text-neutral-200">
              {{ .Site.Params.Author.name | default .Site.Title }}
            </h1>
            {{ with .Site.Params.Author.headline }}
              <h2 class="mt-0 mb-0 text-xl text-neutral-800 dark:text-neutral-300">
                {{ . | markdownify }}
              </h2>
            {{ end }}
          {{ end }}
          <div class="mt-3 mb-10 text-2xl">
            {{ with .Site.Params.Author.links }}
              <div class="flex flex-wrap">
                {{ range $links := . }}
                  {{ range $name, $url := $links }}
                    {{ $isEmail := eq $name "email" }}
                    <a
                      class="px-1 hover:text-primary-400
                      {{ cond $disableHeroImageFilter `text-primary-300` `text-primary-800 dark:text-primary-200` }}
                      {{ cond $isEmail `email-link` `` }}"
                      href="{{ cond $isEmail "#" ($url | safeURL) }}"
                      {{ if $isEmail }}
                        data-email="{{ $url | base64Encode }}"
                        data-subject="Contact"
                      {{ end }}
                      target="_blank"
                      aria-label="{{ $name | title }}"
                      title="{{ $name | title }}"
                      rel="me noopener noreferrer">
                      {{ partial "icon.html" $name }}
                    </a>
                  {{ end }}
                {{ end }}
              </div>
            {{ end }}
          </div>
          {{ if not $disableHeroImageFilter }}
            <section class="prose prose-invert w-full">{{ .Content }}</section>
          {{ else }}
            <section class="prose dark:prose-invert w-full">{{ .Content }}</section>
          {{ end }}
        </div>
      </div>
    </div>
  </div>
</article>
<section>
  {{ partial "recent-articles/main.html" . }}
</section>
