From 5b6f4218be6a2cc5b5e42d4b364ccfecdd181704 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Fri, 22 Aug 2025 00:32:20 +0200 Subject: [PATCH] fix(language-switch): manage icon menu item after the language switcher (#772) * fix(language-switch): manage icon menu item after the language switcher * Just for the demo will be reverted/removed when the PR will be approved * chore: add a warning when an icon menu has no URL * chore: trim the comment * fix: comment * Revert "Just for the demo will be reverted/removed when the PR will be approved" This reverts commit 09cc9fe393b1535973cba36fbbbc27945c23b07d. --- layouts/_partials/navbar.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/layouts/_partials/navbar.html b/layouts/_partials/navbar.html index 932de36..564798a 100644 --- a/layouts/_partials/navbar.html +++ b/layouts/_partials/navbar.html @@ -31,17 +31,18 @@ {{- end -}} {{- end -}} - {{/* Display icon menu item */}} - {{- if .Params.icon -}} + {{- if eq .Params.type "theme-toggle" -}} + {{- partial "theme-toggle.html" (dict "iconHeight" $iconHeight "hideLabel" (not .Params.label) "iconHeight" $iconHeight "location" "top" "class" "hx:p-2") -}} + {{- else if eq .Params.type "language-switch" -}} + {{- partial "language-switch" (dict "context" $page "grow" false "hideLabel" (not .Params.label) "iconName" (.Params.icon | default "translate") "iconHeight" $iconHeight "location" "top" "class" "hx:p-2") -}} + {{- else if .Params.icon -}} + {{- /* Display icon menu item */ -}} + {{- if not $link -}}{{ warnf "Icon menu item '%s' has no URL" .Name }}{{- end -}} {{- $rel := cond (eq .Params.icon "mastodon") "noreferrer me" "noreferrer" }} {{- partial "utils/icon.html" (dict "name" .Params.icon "attributes" (printf "height=%d" $iconHeight)) -}} {{ or (T .Identifier) .Name | safeHTML }} - {{- else if eq .Params.type "theme-toggle" -}} - {{- partial "theme-toggle.html" (dict "iconHeight" $iconHeight "hideLabel" (not .Params.label) "iconHeight" $iconHeight "location" "top" "class" "hx:p-2") -}} - {{- else if eq .Params.type "language-switch" -}} - {{- partial "language-switch" (dict "context" $page "grow" false "hideLabel" (not .Params.label) "iconName" (.Params.icon | default "translate") "iconHeight" $iconHeight "location" "top" "class" "hx:p-2") -}} {{- else -}} {{- $active := or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .) -}} {{- $activeClass := cond $active "hx:font-medium" "hx:text-gray-600 hx:hover:text-gray-800 hx:dark:text-gray-400 hx:dark:hover:text-gray-200" -}}