{{ define "main" }}
  {{ partial "minimal-navbar.html" }}
  {{ $path := "" }}
  {{ with .File }}
    {{ $path = .Path }}
    {{ if eq .Dir "feed/" }}
      <h5>/feed</h5>
    {{ else if eq .Dir "dev/" }}
      <h5>/dev</h5>
    {{ else if eq .Dir "files/" }}
      <h5>/files</h5>
    {{ end }}
  {{ end }}
  {{ $colors := slice "cyan" "yellow" "pink"}}
  {{ if hasPrefix $path "files" }}
    {{ range $folder, $files := .Params.folders }}
      {{ $opt := mod (len $folder) (len $colors) }}
      <div class="card" style="border-color: {{ index $colors $opt }}">
        <h5 class="card-header postcard card-title">{{ $folder }}</h5>
        {{ range $file := $files }}
          <ul>
            <a href={{ print "/files/" $folder "/" $file }}>{{ $file}}</a>
          </ul>
        {{ end }}
      </div>
    {{ end }}
  {{ end }}
  {{ range $i, $page := .Pages.ByDate.Reverse }}
    {{ $opt := mod $i (len $colors) }}
    <div class="card" style="border-color: {{ index $colors $opt }}">
      <a href="{{ anchorize .Page.Name }}">
        <h5 class="card-header postcard card-title">
          {{ .Title }}
          {{ emojify ":link:" }}
        </h5>
      </a>
      <div class="card-body postcard">
        {{  if .Page.Params.Article }}
          <p class="card-text">{{ .Description }}</p>
        {{ else }}
          <!-- for some reason /scripts likes to dump the whole article so this -->
          <!-- is a guard against that and yes its fucking stupid who cares it works -->
          <!-- even if it is absolutely stupid -->
          {{ if not (hasPrefix .Page.Path "/scripts") }}
            <p class="card-text">{{ .Page.Content }}</p>
          {{ end }}
        {{ end }}
        {{  if .Page.Params.Thumbnail }}
          <a href="{{ .Params.Thumbnail }}">
            <img class="card-img" src="{{ .Params.Thumbnail }}">
          </a>
        {{ end }}
      </div>
      <div class="card-footer text-muted postcard">
        {{ .Date | time.Format ":date_short" }} {{ .Date | time.Format ":time_long"}}
      </div>
    </div>
  {{ end }}
{{ end }}
