breadcrumb nav as partial

This commit is contained in:
Aditya Telange 2021-02-08 20:28:55 +05:30
parent 65f84d6f19
commit 43ddff0fde
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77
2 changed files with 19 additions and 18 deletions

View File

@ -2,24 +2,7 @@
<article class="post-single"> <article class="post-single">
<header class="post-header"> <header class="post-header">
{{- if (.Param "ShowBreadCrumbs")}} {{- partial "breadcrumbs.html" . }}
<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 "&nbsp;»&nbsp;" | safeHTML -}}<a href="{{ $bc_pg.Permalink }}">{{ $bc_pg.Name }}</a>
{{- end }}
{{- end }}
</div>
{{- end }}
<h1 class="post-title"> <h1 class="post-title">
{{ .Title }} {{ .Title }}
{{- if .Draft }}<div class="entry-isdraft"><sup>&nbsp;&nbsp;[draft]</sup></div>{{- end }} {{- if .Draft }}<div class="entry-isdraft"><sup>&nbsp;&nbsp;[draft]</sup></div>{{- end }}

View 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 "&nbsp;»&nbsp;" | safeHTML -}}<a href="{{ $bc_pg.Permalink }}">{{ $bc_pg.Name }}</a>
{{- end }}
{{- end }}
</div>
{{- end }}