{{ define "main" }}
<article>
  <header class="post-header">
    <h1 class="post-title">{{ .Title }}</h1>
    <div class="post-meta">
      <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2, 2006" }}</time>
      {{- with .Params.categories }}
      {{- $cat := index . 0 }}
      <span class="post-meta__sep">&mdash;</span>
      {{- with $.Site.GetPage (printf "categories/%s" ($cat | urlize)) }}
      <a href="{{ .Permalink }}" style="color:inherit;text-decoration:none;">{{ $cat }}</a>
      {{- else }}
      {{ $cat }}
      {{- end }}
      {{- end }}
      <span class="post-meta__sep">&mdash;</span>
      {{ .ReadingTime }} min read
    </div>
  </header>

  <div class="post-content">
    {{ .Content }}
  </div>

  <footer class="post-footer">
    {{- with .Params.categories }}
    <div class="post-footer__row">
      <span class="post-footer__label">Category</span>
      {{- range . }}
      {{- $cat := . }}
      {{- with $.Site.GetPage (printf "categories/%s" ($cat | urlize)) }}
      <a href="{{ .Permalink }}" class="tag-pill">{{ $cat }}</a>
      {{- else }}
      <span class="tag-pill">{{ $cat }}</span>
      {{- end }}
      {{- end }}
    </div>
    {{- end }}
    {{- with .Params.tags }}
    <div class="post-footer__row">
      <span class="post-footer__label">Tags</span>
      <div class="post-tags">
        {{- range . }}
        {{- $tag := . }}
        {{- with $.Site.GetPage (printf "tags/%s" ($tag | urlize)) }}
        <a href="{{ .Permalink }}" class="tag-pill">{{ $tag }}</a>
        {{- else }}
        <span class="tag-pill">{{ $tag }}</span>
        {{- end }}
        {{- end }}
      </div>
    </div>
    {{- end }}
  </footer>
</article>
{{ end }}
