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:
parent
db3f1f40fa
commit
a5e5d04b9f
4 changed files with 47 additions and 0 deletions
30
assets/css/099_breadcrumb.css
Normal file
30
assets/css/099_breadcrumb.css
Normal 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
1
i18n/en.yaml
Normal file
|
@ -0,0 +1 @@
|
|||
home: Home
|
|
@ -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">
|
||||
|
|
13
layouts/partials/page_breadcrumb.html
Normal file
13
layouts/partials/page_breadcrumb.html
Normal 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>
|
Loading…
Add table
Add a link
Reference in a new issue