{{- /* Related Content */ -}}
{{- /* https://gohugo.io/content-management/related/ */ -}}
{{- $relatedConfig := dict "Page" . "Key" "related" | partial "function/param.html" -}}
{{- if $relatedConfig.enable | and ("footer" | in $relatedConfig.position) | and (not .Params.password) -}}
  {{- $posts := .Site.Store.Get "mainSectionPages" -}}
  {{- if .Site.Params.hidden_from_related -}}
    {{- $posts = where $posts "Params.hidden_from_related" false -}}
  {{- else -}}
    {{- $posts = where $posts "Params.hidden_from_related" "!=" true -}}
  {{- end -}}
  {{- $related := $posts.Related . | first ($relatedConfig.count | default 5) -}}
  {{- with $related -}}
    <hr class="awesome-hr" />
    <h2 id="see-also">{{ T "single.relatedContent" }}</h2>
    <ul>
      {{- range $i, $p := . -}}
        {{- $title := cond (.Param "capitalize_titles") (title .LinkTitle) .LinkTitle -}}
        <li>
          <a href="{{ .RelPermalink }}" title="{{ $title }}">{{ $title }}</a>
          {{- with .HeadingsFiltered -}}
            <ul>
              {{- range . -}}
                {{- $link := printf "%s#%s" $p.RelPermalink .ID | safeURL -}}
                <li>
                  <a href="{{ $link }}" title="{{ .Title }}">{{ .Title }}</a>
                </li>
              {{- end -}}
            </ul>
          {{- end -}}
        </li>
      {{- end -}}
    </ul>
  {{- end -}}
{{- end -}}
