Rinkusu/layouts/partials/bradcrumb.html
2021-09-23 13:16:17 +02:00

26 lines
1 KiB
HTML

{{"<!-- Bradcrumb Section -->" | safeHTML}}
{{ $siteUrl := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
{{ $.Scratch.Add "sitePath" .Site.BaseURL }}
{{ $.Scratch.Add "siteBreadcrumbs" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) }}
{{ range $index, $element := split $siteUrl "/" }}
{{ $.Scratch.Add "sitePath" $element }}
{{ $.Scratch.Add "sitePath" "/" }}
{{ if ne $element "" }}
{{ $.Scratch.Add "siteBreadcrumbs" (slice (dict "url" ($.Scratch.Get "sitePath") "name" . "position" (add $index 2))) }}
{{ end }}
{{ end }}
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<nav aria-label="breadcrumb">
<!-- <p> You are hear ↓↓↓</p> -->
<ol class="breadcrumb">
{{ range $.Scratch.Get "siteBreadcrumbs" }}
<li class="breadcrumb-item"><a href="{{ .url }}">{{ .name }}</a></li>
{{ end }}
</ol>
</nav>
</div>
</nav>
{{"<!-- /Bradcrumb Section -->" | safeHTML}}