diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html index 3a6bcbbb..b7090011 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navbar.html @@ -31,6 +31,8 @@ {{- range .Site.Menus.main -}} {{- if eq .Params.type "search" -}} {{- partial "search.html" (dict "params" .Params) -}} + {{- else if eq .Params.type "theme-toggle" -}} + {{- partial "theme-toggle.html" (dict "navbar" true "hideLabel" (.Params.hideLabel | default true)) -}} {{- else -}} {{- $link := .URL -}} {{- $external := strings.HasPrefix $link "http" -}} @@ -67,4 +69,4 @@ {{- partial "utils/icon.html" (dict "name" "hamburger-menu" "attributes" "height=24") -}} - + \ No newline at end of file diff --git a/layouts/partials/theme-toggle.html b/layouts/partials/theme-toggle.html index 6a939b56..a6e9932b 100644 --- a/layouts/partials/theme-toggle.html +++ b/layouts/partials/theme-toggle.html @@ -1,3 +1,10 @@ +{{- $navbar := .navbar | default false -}} +{{- $height_px := 12 -}} +{{- $height_tw := "hx-text-xs" -}} +{{- if $navbar -}} + {{- $height_px = 24 -}} + {{- $height_tw = "hx-text-sm" -}} +{{- end -}} {{- $hideLabel := .hideLabel | default false -}} {{- $changeTheme := (T "changeTheme") | default "Change theme" -}} @@ -8,14 +15,14 @@ - {{- partial "utils/icon.html" (dict "name" "sun" "attributes" "height=12 class=\"group-data-[theme=light]:hx-hidden\"") -}} + {{- partial "utils/icon.html" (dict "name" "sun" "attributes" (printf "height=%d class=\"group-data-[theme=light]:hx-hidden\"" $height_px)) -}} {{- if not $hideLabel }}{{ $light }}{{ end -}} - {{- partial "utils/icon.html" (dict "name" "moon" "attributes" "height=12 class=\"group-data-[theme=dark]:hx-hidden\"") -}} + {{- partial "utils/icon.html" (dict "name" "moon" "attributes" (printf "height=%d class=\"group-data-[theme=dark]:hx-hidden\"" $height_px)) -}} {{- if not $hideLabel }}{{ $dark }}{{ end -}}