update breadcrumb and lang-switcher
This commit is contained in:
parent
76ed462707
commit
3cc5995449
@ -1,9 +1,9 @@
|
|||||||
{{ $context := .Context }}
|
{{ $context := .Context }}
|
||||||
{{ $class := .Class }}
|
{{ $class := .Class }}
|
||||||
{{ $base := site.BaseURL }}
|
{{ $base := site.BaseURL }}
|
||||||
{{ $url := replace $context.Permalink ( printf "%s" $base) "" }}
|
{{ $pageLink := replace $context.Permalink $base "" }}
|
||||||
{{ $lang := $context.Lang }}
|
{{ $lang := $context.Lang }}
|
||||||
{{ $.Scratch.Add "path" $base }}
|
{{ $context.Scratch.Set "path" "/" }}
|
||||||
|
|
||||||
|
|
||||||
<ul class="{{ $class }} inline-flex">
|
<ul class="{{ $class }} inline-flex">
|
||||||
@ -14,22 +14,28 @@
|
|||||||
{{ i18n "home" | default "Home" }}
|
{{ i18n "home" | default "Home" }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{ range $index, $element := split $url "/" }}
|
{{ range $index, $element := split $pageLink "/" }}
|
||||||
{{ if ne $element $lang }}
|
{{ if ne $element $lang }}
|
||||||
{{ $.Scratch.Add "path" $element }}
|
{{ $context.Scratch.Add "path" $element }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $.Scratch.Add "path" (add $element "/") }}
|
{{ $context.Scratch.Add "path" (add $element "/") }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if and (ne $element "") (ne $element $lang) }}
|
{{ if and (ne $element "") (ne $element $lang) }}
|
||||||
<li class="text-light dark:text-darkmode-light mx-1 capitalize">
|
<li class="text-light dark:text-darkmode-light mx-1 capitalize">
|
||||||
<span class="inlin-block mr-1">/</span>
|
<span class="inlin-block mr-1">/</span>
|
||||||
<a
|
{{ if eq $element (path.BaseName $pageLink) }}
|
||||||
class="text-primary dark:text-darkmode-primary"
|
<span class="text-primary dark:text-darkmode-primary">
|
||||||
href="{{ $.Scratch.Get `path` }}"
|
{{ . }}
|
||||||
>{{ . }}
|
</span>
|
||||||
</a>
|
{{ else }}
|
||||||
|
<a
|
||||||
|
class="text-primary dark:text-darkmode-primary"
|
||||||
|
href="{{ $context.Scratch.Get `path` }}/">
|
||||||
|
{{ . }}
|
||||||
|
</a>
|
||||||
|
{{ end }}
|
||||||
</li>
|
</li>
|
||||||
{{ $.Scratch.Add "path" "/" }}
|
{{ $context.Scratch.Add "path" "/" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{ $pageLang := $context.Lang }}
|
{{ $pageLang := $context.Lang }}
|
||||||
{{ $base:= urls.Parse site.BaseURL }}
|
{{ $base:= urls.Parse site.BaseURL }}
|
||||||
{{ $siteLanguages := site.Home.AllTranslations }}
|
{{ $siteLanguages := site.Home.AllTranslations }}
|
||||||
{{ $pageLink := replace (replace (replace $context.RelPermalink $pageLang "") "//" "/") $base.Path "" }}
|
{{ $pageLink := replace (replace (replace $context.RelPermalink $pageLang "") "//" "/") $base.Path "/" }}
|
||||||
|
|
||||||
{{ if $context.IsTranslated }}
|
{{ if $context.IsTranslated }}
|
||||||
<select class="{{ $class }}" onchange="location = this.value">
|
<select class="{{ $class }}" onchange="location = this.value">
|
||||||
|
Loading…
Reference in New Issue
Block a user