mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-12-22 17:15:07 +01:00
breadcrumb nav as partial
This commit is contained in:
parent
65f84d6f19
commit
43ddff0fde
@ -2,24 +2,7 @@
|
||||
|
||||
<article class="post-single">
|
||||
<header class="post-header">
|
||||
{{- if (.Param "ShowBreadCrumbs")}}
|
||||
<div class="breadcrumbs">
|
||||
{{- $url := replace .Parent.Permalink ( printf "%s" .Site.BaseURL) "" }}
|
||||
{{- $lang_url := replace $url ( printf "%s" .Lang) "" }}
|
||||
|
||||
<a href="{{ "" | absLangURL }}">{{ i18n "home" | default "Home"}}</a>
|
||||
{{- range $index, $element := split $lang_url "/" }}
|
||||
|
||||
{{- $.Scratch.Add "path" (printf "%s/" $element )}}
|
||||
{{- $bc_pg := $.Site.GetPage ($.Scratch.Get "path") -}}
|
||||
|
||||
{{- if (and ($bc_pg) (gt (len . ) 0))}}
|
||||
{{- print " » " | safeHTML -}}<a href="{{ $bc_pg.Permalink }}">{{ $bc_pg.Name }}</a>
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- partial "breadcrumbs.html" . }}
|
||||
<h1 class="post-title">
|
||||
{{ .Title }}
|
||||
{{- if .Draft }}<div class="entry-isdraft"><sup> [draft]</sup></div>{{- end }}
|
||||
|
18
layouts/partials/breadcrumbs.html
Normal file
18
layouts/partials/breadcrumbs.html
Normal file
@ -0,0 +1,18 @@
|
||||
{{- if (.Param "ShowBreadCrumbs")}}
|
||||
<div class="breadcrumbs">
|
||||
{{- $url := replace .Parent.Permalink ( printf "%s" .Site.BaseURL) "" }}
|
||||
{{- $lang_url := replace $url ( printf "%s" .Lang) "" }}
|
||||
|
||||
<a href="{{ "" | absLangURL }}">{{ i18n "home" | default "Home"}}</a>
|
||||
{{- range $index, $element := split $lang_url "/" }}
|
||||
|
||||
{{- $.Scratch.Add "path" (printf "%s/" $element )}}
|
||||
{{- $bc_pg := $.Site.GetPage ($.Scratch.Get "path") -}}
|
||||
|
||||
{{- if (and ($bc_pg) (gt (len . ) 0))}}
|
||||
{{- print " » " | safeHTML -}}<a href="{{ $bc_pg.Permalink }}">{{ $bc_pg.Name }}</a>
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
</div>
|
||||
{{- end }}
|
Loading…
Reference in New Issue
Block a user