{{ define "head"}}
<meta name="description" content="{{ .Params.description }}" />
<title>{{ .Title }}</title>
{{ end }}


{{ define "main" }}

<section class="bg-light">
  <div class="container">
    <div class="row justify-content-md-center">
      <div class="col-md-8">
        <!-- title and date -->
        <div class="p-2">
          <h1>{{.Title}}</h1>
          <div class="text-muted">
            <!-- Date -->
            <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-calendar" fill="currentColor"
              xmlns="http://www.w3.org/2000/svg">
              <path fill-rule="evenodd"
                d="M1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1zm1-3a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2H2z" />
              <path fill-rule="evenodd"
                d="M3.5 0a.5.5 0 0 1 .5.5V1a.5.5 0 0 1-1 0V.5a.5.5 0 0 1 .5-.5zm9 0a.5.5 0 0 1 .5.5V1a.5.5 0 0 1-1 0V.5a.5.5 0 0 1 .5-.5z" />
            </svg>
            {{ dateFormat "Jan 2, 2006" .Date }}

            <!-- Author -->
            {{ if .Params.author }}
            <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-person-fill" fill="currentColor"
              xmlns="http://www.w3.org/2000/svg">
              <path fill-rule="evenodd"
                d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6z" />
            </svg>
            {{ .Params.author }}
            {{ end }}

            <!-- Edit in Github -->
            {{ if .Params.github_link }}
            <a href="{{ .Params.github_link }}" target="_blank" title="Edit on github">
              <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-pencil float-right" fill="currentColor"
                xmlns="http://www.w3.org/2000/svg">
                <path fill-rule="evenodd"
                  d="M11.293 1.293a1 1 0 0 1 1.414 0l2 2a1 1 0 0 1 0 1.414l-9 9a1 1 0 0 1-.39.242l-3 1a1 1 0 0 1-1.266-1.265l1-3a1 1 0 0 1 .242-.391l9-9zM12 2l2 2-9 9-3 1 1-3 9-9z" />
                <path fill-rule="evenodd"
                  d="M12.146 6.354l-2.5-2.5.708-.708 2.5 2.5-.707.708zM3 10v.5a.5.5 0 0 0 .5.5H4v.5a.5.5 0 0 0 .5.5H5v.5a.5.5 0 0 0 .5.5H6v-1.5a.5.5 0 0 0-.5-.5H5v-.5a.5.5 0 0 0-.5-.5H3z" />
              </svg>
            </a>
            {{ end}}
          </div>
        </div>

        {{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
        {{ $.Scratch.Add "path" .Site.BaseURL }}
        <nav aria-label="breadcrumb">
          <ol class="breadcrumb">
            <li class="breadcrumb-item" aria-current="page">
              <a href="/">home</a>
            </li>
            {{ range $index, $element := split $url "/" }}
            {{ $.Scratch.Add "path" $element }}
            {{ if ne $element "" }}
            <li class="breadcrumb-item" aria-current="page">
              <a href='{{ $.Scratch.Get "path" }}'>{{ . }}</a>
            </li>
            {{ $.Scratch.Add "path" "/" }}
            {{ end }}
            {{ end }}
          </ol>
        </nav>

        <!-- image -->
        <div class="py-2">
          {{ with .Params.bg_image }}
          <img class="img-fluid" src="{{ . }}">
          {{ end }}
        </div>

        <!-- content -->
        <article>
          {{.Content}}
        </article>

        <!-- Tags -->
        <div class="mb-4 p-5">
          <div class="card">
            <h5 class="card-header m-0">Tags</h5>
            <div class=" card-body">
              {{ if .Params.tags }}
              {{ range $tags := .Params.tags }}
              {{ with $.Site.GetPage (printf "/tags/%s" $tags) }}
              <a href="{{ .RelPermalink }}" class="btn btn-info btn-rounded mb-2">{{ $tags }}</a>
              {{ end }}
              {{ end }}
              {{ end }}
            </div>
            </a>
          </div>
        </div>

        
        {{ template "_internal/disqus.html" . }}

      </div>
    </div>
  </div>
</section>
{{ end }}
