page_breadcrumb: Implement a breadcrumb and display it above the <main> content

The breadcrumb shows navigation from the home page as a path:

/ > Posts > This Post

en.yaml
This commit is contained in:
Eryn Wells 2024-07-03 07:33:51 -07:00
parent db3f1f40fa
commit a5e5d04b9f
4 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,30 @@
/*************
# BREADCRUMB
*************/
.nav-breadcrumb {
font-size: var(--text-s);
ul, ol {
display: flex;
padding-inline: 0;
}
li {
list-style-type: none;
}
li:not(:first-child) {
margin-inline-start: var(--space-xs);
&::before {
content: "";
margin-inline-end: var(--space-xs);
}
}
}

1
i18n/en.yaml Normal file
View file

@ -0,0 +1 @@
home: Home

View file

@ -9,6 +9,9 @@
{{ partial "site/header.html" . }}
</header>
<main>
{{ if not .IsNode }}
{{ partial "page_breadcrumb.html" . }}
{{ end }}
{{ block "main" . }}{{ end }}
</main>
<footer class="site-footer">

View file

@ -0,0 +1,13 @@
<nav class="nav-breadcrumb">
<ol>
{{ range .Ancestors.Reverse }}
{{- $title := .LinkTitle -}}
{{- if .IsHome -}}
{{ $title = "/" }}
{{- end -}}
<li><a href="{{ .Permalink }}">{{ $title }}</a></li>
{{ end }}
<li class="nav-breadcrumb__active"><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
</ol>
</nav>