{{ define "main" }}
  {{- $next_page := .CurrentSection.Pages.Prev . }}
  {{- $current := . }}
  {{- range .Ancestors }}
    {{ with .Pages.Prev $current }}
      {{ $next_page = . }}
      {{ break }}
    {{ end }}
    {{ $current = . }}
  {{- end }}
  {{- $prev_page := .CurrentSection.Pages.Next . }}
  {{- $prev_section := .Parent }}
  <h1>{{ .Title }}</h1>
  <p class="subtitle">Reading time: about {{ .ReadingTime }} min</p>
  <hr>
  <nav class="page-nav">
    {{ with or $prev_page $prev_section }}<a class="prev" title="Previous page" href="{{.RelPermalink}}">&lt; {{ .Title }}</a>{{ end }}
    {{ with $next_page }}<a class="next" title="Next page" href="{{.RelPermalink}}">{{ .Title }} &gt;</a>{{ end }}
  </nav>
  <hr>
  {{ .Summary }}
  {{- if .Params.show_toc -}}
  <hr>
  {{ .TableOfContents }}
  <hr>
  {{- end }}
  {{ .ContentWithoutSummary }}
  <hr>
  <nav class="page-nav">
    {{ with or $prev_page $prev_section }}<a class="prev" title="Previous page" href="{{.RelPermalink}}">&lt; {{ .Title }}</a>{{ end }}
    {{ with $next_page }}<a class="next" title="Next page" href="{{.RelPermalink}}">{{ .Title }} &gt;</a>{{ end }}
  </nav>
{{ end }}
