{{- $params := .Params | merge .Site.Params.page -}}

<article class="single summary" itemscope itemtype="http://schema.org/Article">
  {{- /* Featured image */ -}}
  {{- $image := $params.featuredimagepreview | default $params.featuredimage -}}
  {{- with .Resources.GetMatch "featured-image" -}}
    {{- $image = .RelPermalink -}}
  {{- end -}}
  {{- with .Resources.GetMatch "featured-image-preview" -}}
    {{- $image = .RelPermalink -}}
  {{- end -}}
  {{- with $image -}}
    <div class="featured-image-preview">
      <a href="{{ $.RelPermalink }}" aria-label="{{ $.Title }}">
        {{- dict "Src" . "Title" $.Description "Resources" $.Resources | partial "plugin/image.html" -}}
      </a>
    </div>
  {{- end -}}

  {{- /* Title */ -}}
  <h1 class="single-title" itemprop="name headline">
    {{ $repost := $params.repost | default dict }}
    {{- with $repost -}}
      {{- if eq .Enable true -}}
        {{- $icon := dict "Class" "fa-solid fa-share fa-fw" -}}
        {{- $title := cond (hasPrefix .Url "http") (printf "%v -> %v" (T "repost") .Url ) (T "repost") -}}
        <span title="{{ $title }}" class="icon-repost">{{- $icon | partial "plugin/icon.html" -}}</span>
      {{- end -}}
    {{- end -}}
    <a href="{{ .RelPermalink }}">{{ .Title }}</a>
  </h1>

  {{- /* Meta */ -}}
  <div class="post-meta">
    {{- partial "single/post-author.html" . -}}

    {{- with .Site.Params.dateFormat | default "2006-01-02" | .PublishDate.Format -}}
      &nbsp;<span class="post-publish" title='{{ "2006-01-02 15:04:05" | $.PublishDate.Format }}'>
        {{- printf `<time datetime="%v">%v</time>` . . | dict "Date" | T "publishedOnDate" | safeHTML -}}
      </span>
    {{- end -}}

    {{- $categories := slice -}}
    {{- range .Params.categories -}}
      {{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
      {{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` (replace $category.RelPermalink "#" "%23") (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
    {{- end -}}
    {{- with delimit $categories "&ensp;" -}}
      &nbsp;<span class="post-category">
        {{- dict "Categories" . | T "includedInCategories" | safeHTML -}}
      </span>
    {{- end -}}
  </div>

  {{- /* Summary content */ -}}
  <div class="content">
    {{- with .Summary -}}
      {{- dict "Content" . "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
    {{- else -}}
      {{- .Description | safeHTML -}}
    {{- end -}}
  </div>

  {{- /* Footer */ -}}
  <div class="post-footer">
    <a href="{{ .RelPermalink }}">{{ T "readMore" }}</a>
    {{- with .Params.tags -}}
      <div class="post-tags">
        {{- dict "Class" "fa-solid fa-tags fa-fw me-1" | partial "plugin/icon.html" -}}
        {{- range $value := . -}}
          {{- $tag := partialCached "function/path.html" $value $value | printf "/tags/%v" | $.Site.GetPage -}}
          {{- with $tag -}}
            <a href='{{ replace .RelPermalink "#" "%23" }}' class="post-tag">{{ .Title }}</a>
          {{- end -}}
        {{- end -}}
      </div>
    {{- end -}}
  </div>
</article>
