{{ define "main" }}

{{ partial "page_nav.html" . }}

<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    <h1 class="posttitle" itemprop="name headline">
      {{ .Title }}
    </h1>

    <div class="meta">
      {{ if (or (isset .Site "author") (isset .Site "title")) }}
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">
          {{ if isset .Site "author" }}
            {{ .Site.Author }}
          {{ else }}
            {{ .Site.Title }}
          {{ end }}
        </span>
      </span>
      {{ end }}

      <div class="postdate">
        {{ $dataFormat := .Site.Params.dateFormat | default "2006-01-02" }}
        <time datetime="{{ .Date }}" itemprop="datePublished">
          {{ .Date.Format $dataFormat }}
        </time>

        {{ if (and .Site.Params.show_updated (ne .Lastmod .Date)) }}
          (Updated:
          <time datetime="{{ .Lastmod }}" itemprop="dateModified">
            {{ .Lastmod.Format $dataFormat }}
          </time>)
        {{ end }}
      </div>

      {{ if .Site.Params.showReadTime }}
      <div class="article-read-time">
        <i class="far fa-clock"></i>
        {{ math.Round (div (countwords .Content) 220.0) }} minute read
      </div>
      {{ end }}

      {{ if gt (len .Params.categories) 0 }}
      <div class="article-category">
        <i class="fas fa-archive"></i>
        {{ range $index, $value := .Params.categories }}
          {{ if gt $index 0 }}, {{ end }}
          <a href="{{ "/categories/" | relLangURL }}{{ $value | urlize }}">
            {{ $value }}
          </a>
        {{ end }}
      </div>
      {{ end }}

      {{ if gt (len .Params.tags) 0 }}
      <div class="article-tag">
        <i class="fas fa-tag"></i>
        {{ range $index, $value := .Params.tags }}
          {{ if gt $index 0 }}, {{ end }}
          <a href="{{ "/tags/" | relLangURL }}{{ $value | urlize }}">
            {{ $value }}
          </a>
        {{ end }}
      </div>
      {{ end }}
    </div>
  </header>

  {{ with .Resources.ByType "image" }}
  <div class="article-gallery">
    {{ range . }}
      <a class="gallery-item" href="{{ .RelPermalink }}">
        <img src="{{ .RelPermalink }}" loading="lazy" />
      </a>
    {{ end }}
  </div>
  {{ end }}

  {{ if .Site.Params.tocInline }}
  <div id="toc">
    {{ .TableOfContents }}
  </div>
  {{ end }}

  <div class="content" itemprop="articleBody">
    {{ .Content }}
  </div>
</article>

{{ if .Site.Params.enableGiscus }}
  {{ partial "comment.html" . }}
{{ end }}

{{ partial "page_nav_mobile.html" . }}

{{ end }}