2023-09-11 23:22:49 +00:00
|
|
|
{{- $ctx := "" -}}
|
|
|
|
{{- $dir := default "down" -}}
|
|
|
|
{{- if (reflect.IsMap . ) -}}
|
|
|
|
{{- $ctx = .ctx -}}
|
|
|
|
{{- $dir = cond (not .dir) nil .dir -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $ctx = . -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{ with page }}
|
|
|
|
{{ if .IsTranslated }}
|
|
|
|
{{ $currentLang := .Page.Lang }}
|
|
|
|
{{ if site.IsMultiLingual }}
|
2023-12-26 00:56:32 +00:00
|
|
|
<div class="group relative">
|
2023-09-11 23:22:49 +00:00
|
|
|
<button
|
2023-12-26 00:56:32 +00:00
|
|
|
class="group-dark:hover:text-primary-400 flex w-full items-center justify-end transition-colors group-hover:text-primary-600"
|
2023-09-11 23:22:49 +00:00
|
|
|
>
|
|
|
|
{{ partial "icon.html" "translate" }}<span class="text-sm">{{ .Lang | upper }}</span
|
|
|
|
><span class="text-[0.6rem]"
|
|
|
|
>{{ partial "icon.html" (cond (eq $dir "down") "chevron-down" "chevron-up") }}</span
|
2023-06-04 00:20:41 +00:00
|
|
|
>
|
2023-09-11 23:22:49 +00:00
|
|
|
</button>
|
|
|
|
{{ if eq $dir "down" }}
|
2023-12-26 00:56:32 +00:00
|
|
|
<div class="invisible h-2 w-full bg-transparent group-hover:visible"></div>
|
2023-09-11 23:22:49 +00:00
|
|
|
{{ end }}
|
|
|
|
<div
|
2023-12-26 00:56:32 +00:00
|
|
|
class="{{ cond (eq $dir "down") "top-8" "bottom-7" }} invisible absolute z-50 flex flex-col whitespace-nowrap rounded border border-neutral-300 bg-neutral text-start text-base shadow group-hover:visible ltr:right-0 rtl:left-0 dark:border-neutral-600 dark:bg-neutral-800"
|
2023-09-11 23:22:49 +00:00
|
|
|
>
|
|
|
|
{{ $siteLanguages := site.Languages }}
|
|
|
|
{{ $pageLang := .Page.Lang }}
|
|
|
|
{{ range .Page.AllTranslations }}
|
|
|
|
{{ $translation := . }}
|
|
|
|
{{ range $siteLanguages }}
|
|
|
|
{{ if eq $translation.Lang .Lang }}
|
|
|
|
{{ $selected := false }}
|
|
|
|
<div class="flex flex-grow">
|
|
|
|
{{ if eq $pageLang .Lang }}
|
|
|
|
<a
|
|
|
|
href="{{ $translation.RelPermalink }}"
|
2023-12-26 00:56:32 +00:00
|
|
|
class="flex w-full items-center justify-between bg-primary-100 px-2 py-1 dark:bg-primary-900"
|
2023-09-11 23:22:49 +00:00
|
|
|
>{{ .LanguageName }}<span
|
2023-12-26 00:56:32 +00:00
|
|
|
class="ms-2 w-6 text-primary-600 dark:text-primary-400"
|
2023-09-11 23:22:49 +00:00
|
|
|
>{{ partial "icon.html" "check" }}</span
|
|
|
|
></a
|
|
|
|
>
|
|
|
|
{{ else }}
|
|
|
|
<a
|
|
|
|
href="{{ $translation.RelPermalink }}"
|
|
|
|
class="w-full py-1 pe-10 ps-2 decoration-primary-500 hover:underline hover:decoration-2 hover:underline-offset-2"
|
|
|
|
>{{ .LanguageName }}</a
|
|
|
|
>
|
|
|
|
{{ end }}
|
|
|
|
</div>
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-11 01:00:27 +00:00
|
|
|
{{ end }}
|
2023-09-11 23:22:49 +00:00
|
|
|
{{ end }}
|
2022-01-11 01:00:27 +00:00
|
|
|
{{ end }}
|