chill_hugoplate/layouts/partials/components/breadcrumb.html

42 lines
1.2 KiB
HTML
Raw Normal View History

2023-06-04 07:29:21 +00:00
{{ $context := .Context }}
{{ $class := .Class }}
{{ $base := site.BaseURL }}
2023-06-04 09:18:31 +00:00
{{ $pageLink := replace $context.Permalink $base "" }}
2023-06-04 07:29:21 +00:00
{{ $lang := $context.Lang }}
2023-06-04 09:18:31 +00:00
{{ $context.Scratch.Set "path" "/" }}
2023-06-04 07:29:21 +00:00
<ul class="{{ $class }} inline-flex">
2023-06-04 05:07:38 +00:00
<li class="mx-1 capitalize">
2023-06-04 07:29:21 +00:00
<a
class="text-primary dark:text-darkmode-primary"
href="{{ $base | relLangURL }}">
{{ i18n "home" | default "Home" }}
</a>
2023-06-04 05:07:38 +00:00
</li>
2023-06-04 09:18:31 +00:00
{{ range $index, $element := split $pageLink "/" }}
2023-06-04 05:07:38 +00:00
{{ if ne $element $lang }}
2023-06-04 09:18:31 +00:00
{{ $context.Scratch.Add "path" $element }}
2023-06-04 05:07:38 +00:00
{{ else }}
2023-06-04 09:18:31 +00:00
{{ $context.Scratch.Add "path" (add $element "/") }}
2023-06-04 05:07:38 +00:00
{{ end }}
{{ if and (ne $element "") (ne $element $lang) }}
<li class="text-light dark:text-darkmode-light mx-1 capitalize">
<span class="inlin-block mr-1">/</span>
2023-06-04 09:18:31 +00:00
{{ if eq $element (path.BaseName $pageLink) }}
<span class="text-primary dark:text-darkmode-primary">
{{ . }}
</span>
{{ else }}
<a
class="text-primary dark:text-darkmode-primary"
href="{{ $context.Scratch.Get `path` }}/">
{{ . }}
</a>
{{ end }}
2023-06-04 05:07:38 +00:00
</li>
2023-06-04 09:18:31 +00:00
{{ $context.Scratch.Add "path" "/" }}
2023-06-04 05:07:38 +00:00
{{ end }}
{{ end }}
</ul>