{{ $page := . }}

{{ with .Ancestors }}
    <nav aria-label="{{ i18n `paige_breadcrumbs` }}" class="mt-3" id="paige-breadcrumbs">
        <div class="d-flex justify-content-center">
            <ol class="breadcrumb mb-0">
                {{ $reverse := .Reverse }}

                {{ $last := sub (len $reverse) 1 }}

                {{ range $i, $ancestor := $reverse }}
                    {{ $title := $ancestor.Title }}

                    {{ if and (eq $i $last) (not $title) }}
                        {{ $title = $page.Param "paige.site_title" | default (site.Title) }}
                    {{ end }}

                    <li class="breadcrumb-item"><a href="{{ .RelPermalink }}">{{ $title | markdownify | plainify | htmlUnescape }}</a></li>
                {{ end }}
            </ol>
        </div>
    </nav>
{{ end }}
