{{ define "header" }}
  {{ partial "page-header.html" . }}
{{ end }}

{{ define "main" }}
  {{ $section := .Site.GetPage "section" .Section }}
  <article class="flex-l flex-wrap justify-between mw8 center ph3 ph4-ns">
    {{ $hasAside := or (.Params.toc) (.Site.RegularPages.Related .)}}

    <header class="mt4 w-100 w-two-thirds-l
                   {{ if $hasAside }} pr4-l{{ else }} center{{ end }}">
      <h1 class="f1 mb1">
        {{- .Title -}}
      </h1>
      {{ if .Params.author }}
      <p class="flex items-center tracked">
        By
        {{ with .Params.authorAvatar }}
        <img class="w2 br-100 mh2 ba" src="/avatars/{{ . }}.jpg" alt="avatar" />
        {{ end }}
        {{ .Params.author | markdownify }}
      </p>
      {{ end }}
      {{/* Hugo uses Go's date formatting is set by example. Here are two
      formats */}}
      {{ if .Date }}
      <time class="f6 mv1 dib tracked" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
        {{- .Date.Format "2006-01-02" -}}
      </time>
      {{ end }}
      {{/*
          Show "reading time" and "word count" but only if one of the following are true:
          1) A global config `params` value is set `show_reading_time = true`
          2) A section front matter value is set `show_reading_time = true`
          3) A page front matter value is set `show_reading_time = true`
        */}}
      {{ if (or (eq (.Param "show_reading_time") true) (eq $section.Params.show_reading_time true) )}}
        <span class="f6 mv4 dib tracked"> - {{ .ReadingTime}} minutes read</span>
        <span class="f6 mv4 dib tracked"> - {{ .WordCount}} words</span>
      {{ end }}
    </header>

    <section class="lh-copy f5 nested-img mid-gray w-two-thirds-l
                    {{ if $hasAside }} pr4-l{{ else }} center{{ end }}">
      {{- .Content -}}
      <hr/>
      <div class="tr f5 mv1">
        We welcome your <a href="{{ .Site.Params.email }}">feedback by email</a>.
      </div>
      {{- partial "tags.html" . -}}
      <div class="mt6">
      {{ if .Site.DisqusShortname }}
        {{ template "_internal/disqus.html" . }}
      {{ end }}
      {{ if .Site.Params.commentoEnable }}
        {{- partial "commento.html" . -}}
      {{ end }}
      </div>
    </section>

    {{ if $hasAside }}
    <aside class="w-third-l">
      {{- partial "menu-contextual.html" . -}}
    </aside>
    {{ end }}

  </article>
{{ end }}
