update breadcrumb, lang-switcher

This commit is contained in:
somrat sorkar 2023-06-04 11:07:38 +06:00
parent 0dec449704
commit fb0fa2d9ef
6 changed files with 41 additions and 28 deletions

BIN
exampleSite/assets/images/banner.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 79 KiB

View File

@ -4,7 +4,7 @@
<section class="section pt-14"> <section class="section pt-14">
<div class="container"> <div class="container">
<div class="row justify-center"> <div class="row justify-center">
<div class="lg:col-7 mb-16 text-center"> <div class="lg:col-7 mb-8 text-center">
<h1 class="mb-4"> <h1 class="mb-4">
{{ .title | markdownify }} {{ .title | markdownify }}
</h1> </h1>
@ -21,7 +21,7 @@
{{ end }} {{ end }}
</div> </div>
<div class="col-12"> <div class="col-12">
{{ partial "image" (dict "Src" .image "Alt" "Banner image" "Loading" "eager" "Class" "mx-auto") }} {{ partial "image" (dict "Src" .image "Alt" "Banner image" "Loading" "eager" "Class" "mx-auto" "Size" "800x") }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,26 @@
{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
{{ $lang := .Lang | urlize }}
{{ $.Scratch.Add "path" .Site.BaseURL }}
<ul class="breadcrumb mt-6 inline-flex">
<li class="mx-1 capitalize">
<a class="text-primary dark:text-darkmode-primary" href="/">Home</a>
</li>
{{ range $index, $element := split $url "/" }}
{{ if ne $element $lang }}
{{ $.Scratch.Add "path" $element }}
{{ else }}
{{ $.Scratch.Add "path" (add $element "/") }}
{{ 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>
<a
class="text-primary dark:text-darkmode-primary"
href="{{ $.Scratch.Get `path` }}"
>{{ . }}
</a>
</li>
{{ $.Scratch.Add "path" "/" }}
{{ end }}
{{ end }}
</ul>

View File

@ -1,18 +1,25 @@
<!-- Language List --> <!-- Language List -->
{{ $class := .Class }} {{ $class := .Class }}
{{ $context := .Context }} {{ $context := .Context }}
{{ $siteLanguages := site.Home.AllTranslations }}
{{ $pageLang := $context.Lang }}
{{ $pageLink := replace $context.RelPermalink $pageLang "" }}
{{ $pageLink = replace $pageLink "//" "/" }}
{{ if $context.IsTranslated }} {{ if $context.IsTranslated }}
<select class="{{ $class }}" onchange="location = this.value"> <select class="{{ $class }}" onchange="location = this.value">
{{ $siteLanguages := site.Home.AllTranslations }}
{{ $pageLang := $context.Lang }}
{{ range $siteLanguages }} {{ range $siteLanguages }}
{{ if eq (string $pageLang) (string .Language) }} {{ if eq (string $pageLang) (string .Language) }}
<option id="{{ .Language }}" value="{{ .RelPermalink }}" selected> <option
id="{{ .Language }}"
value="{{ replace (add .RelPermalink $pageLink) `//` `/` }}"
selected>
{{ .Language.LanguageName }} {{ .Language.LanguageName }}
</option> </option>
{{ else }} {{ else }}
<option id="{{ .Language }}" value="{{ .RelPermalink }}"> <option
id="{{ .Language }}"
value="{{ replace (add .RelPermalink $pageLink) `//` `/` }}">
{{ .Language.LanguageName }} {{ .Language.LanguageName }}
</option> </option>
{{ end }} {{ end }}

View File

@ -3,27 +3,7 @@
<div <div
class="from-body to-theme-light dark:from-darkmode-body dark:to-darkmode-theme-light rounded-2xl bg-gradient-to-b px-8 py-14"> class="from-body to-theme-light dark:from-darkmode-body dark:to-darkmode-theme-light rounded-2xl bg-gradient-to-b px-8 py-14">
<h1>{{ .Title | title }}</h1> <h1>{{ .Title | title }}</h1>
{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }} {{ partial "components/breadcrumb" . }}
{{ $.Scratch.Add "path" .Site.BaseURL }}
<ul class="breadcrumb mt-6 inline-flex">
<li class="mx-1 capitalize">
<a class="text-primary dark:text-darkmode-primary" href="/">Home</a>
</li>
{{ range $index, $element := split $url "/" }}
{{ $.Scratch.Add "path" $element }}
{{ if ne $element "" }}
<li class="text-light dark:text-darkmode-light mx-1 capitalize">
<span class="inlin-block mr-1">/</span>
<a
class="text-primary dark:text-darkmode-primary"
href="{{ $.Scratch.Get `path` }}"
>{{ . }}</a
>
</li>
{{ $.Scratch.Add "path" "/" }}
{{ end }}
{{ end }}
</ul>
</div> </div>
</div> </div>
</section> </section>

View File

@ -1,7 +1,7 @@
{ {
"name": "hugoplate", "name": "hugoplate",
"description": "hugo tailwindcss boilerplate", "description": "hugo tailwindcss boilerplate",
"version": "1.0.5", "version": "1.1.0",
"license": "MIT", "license": "MIT",
"author": "zeon.studio", "author": "zeon.studio",
"scripts": { "scripts": {