Skip to content

Commit

Permalink
feat: add optional breadcrumb trail
Browse files Browse the repository at this point in the history
  • Loading branch information
h-enk committed Mar 5, 2021
1 parent 7eeba78 commit 9c67aca
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions assets/scss/layouts/_pages.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ p.meta {
margin-top: 0.5rem;
font-size: $font-size-base;
}

.breadcrumb {
margin-top: 2.25rem;
font-size: $font-size-base;
}
1 change: 1 addition & 0 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ editPage = false
flexSearch = true
darkMode = true
bootStrapJs = false
breadCrumb = false
11 changes: 10 additions & 1 deletion layouts/docs/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="col-lg-5 col-xl-4 docs-sidebar">
<nav class="docs-links" aria-label="Main navigation">
{{ partial "sidebar/docs-menu.html" . }}
</nav>
</nav>
</div>
{{ if ne .Params.toc false -}}
<nav class="docs-toc d-none d-xl-block col-xl-3" aria-label="Secondary navigation">
Expand All @@ -15,6 +15,15 @@
{{ else -}}
<main class="docs-content col-lg-11 col-xl-9 mx-xl-auto">
{{ end -}}
{{ if .Site.Params.options.breadCrumb -}}
<!-- https://discourse.gohugo.io/t/breadcrumb-navigation-for-highly-nested-content/27359/6 -->
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
{{ partial "main/breadcrumb" . -}}
<li class="breadcrumb-item active" aria-current="page">{{ .Title }}</li>
</ol>
</nav>
{{ end }}
<h1>{{ .Title }}</h1>
<p class="lead">{{ .Params.lead | safeHTML }}</p>
{{ partial "main/headline-hash.html" .Content }}
Expand Down
4 changes: 4 additions & 0 deletions layouts/partials/main/breadcrumb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ with .Parent -}}
{{ partial "main/breadcrumb.html" . -}}
<li class="breadcrumb-item"><a href="{{ .Permalink }}">{{ if .IsHome }}Home{{ else }}{{ .Title }}{{ end }}</a></li>
{{ end -}}

0 comments on commit 9c67aca

Please sign in to comment.