{{ define "main" }}
<article class="post">
  <h1 class="post-title">
    <a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
  </h1>
  {{ partial "post-meta.html" . }}

  {{ if .Params.tags }}
    <span class="post-tags">
      {{ range .Params.tags }}
      #<a href="{{ (urlize (printf "tags/%s/" .)) | absLangURL }}">{{ . }}</a>&nbsp;
      {{ end }}
    </span>
  {{ end }}
  {{ partial "cover.html" . }}

  {{ if (.Params.Toc | default .Site.Params.Toc) }}
    <div class="table-of-contents">
      <h1>
        {{ (.Params.TocTitle | default .Site.Params.TocTitle) | default "Table of Contents" }}
      </h1>
      {{ .TableOfContents }}
    </div>
  {{ end }}

  <div class="post-content">
    {{- with .Content -}}
      <div>
        {{ . | replaceRE "(<h[1-9] id=\"([^\"]+)\".+)(</h[1-9]+>)" `${1}<a href="#${2}" class="hanchor" ariaLabel="Anchor">#</a> ${3}` | safeHTML }}
      </div>
    {{- end -}}
  </div>

  {{ if eq .Type $.Site.Params.contentTypeName }}
    {{ partial "posts_pagination.html" . }}
  {{ end }}

  {{ if not (.Params.hideComments | default false) }}
    {{ partial "comments.html" . }}
  {{ end }}
</article>
{{ end }}
