🐛 Fix empty `li` output when no locales available

Fixes #678
pull/687/head
James Panther 2023-10-26 13:30:47 +11:00
parent e689e54112
commit 70f668e644
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
5 changed files with 57 additions and 41 deletions

View File

@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed
- Empty block is output when locale switcher is hidden ([#678](https://github.com/jpanther/congo/issues/678))
- Extra whitespace added after links ([#679](https://github.com/jpanther/congo/issues/679))
## [2.7.1] - 2023-10-24

View File

@ -2,9 +2,12 @@
{{/* Footer menu */}}
{{ if .Site.Menus.footer }}
<nav class="pb-4 text-base font-medium text-neutral-500 dark:text-neutral-400">
<ul class="flex list-none flex-col sm:flex-row">
<ul class="flex flex-col list-none sm:flex-row">
{{ range .Site.Menus.footer }}
<li class="group mb-1 text-end sm:mb-0 sm:me-7 sm:last:me-0">
{{ if and (eq .Params.action "locale") (and (not page.IsTranslated) (not site.IsMultiLingual)) }}
{{ continue }}
{{ end }}
<li class="mb-1 group text-end sm:mb-0 sm:me-7 sm:last:me-0">
{{ if eq .Params.action "search" }}
{{ $.Scratch.Add "searchCount" 1 }}
{{ if $.Site.Params.enableSearch | default false }}
@ -14,7 +17,7 @@
>
{{ with .Params.icon }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -34,13 +37,13 @@
aria-label="appearance switcher"
>
<span
class="group-dark:hover:text-primary-400 inline transition-colors group-hover:text-primary-600 dark:hidden"
class="inline transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:hidden"
title="{{ i18n "footer.dark_appearance" }}"
>
{{ partial "icon.html" "moon" }}
</span>
<span
class="group-dark:hover:text-primary-400 hidden transition-colors group-hover:text-primary-600 dark:inline"
class="hidden transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:inline"
title="{{ i18n "footer.light_appearance" }}"
>
{{ partial "icon.html" "sun" }}
@ -56,7 +59,7 @@
{{ with .Params.target }}target="{{ . }}"{{ end }}
>{{ with .Params.icon }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -114,13 +117,13 @@
>
<button id="appearance-switcher-0" type="button" aria-label="appearance switcher">
<div
class="flex h-12 w-12 items-center justify-center dark:hidden"
class="flex items-center justify-center w-12 h-12 dark:hidden"
title="{{ i18n "footer.dark_appearance" }}"
>
{{ partial "icon.html" "moon" }}
</div>
<div
class="hidden h-12 w-12 items-center justify-center dark:flex"
class="items-center justify-center hidden w-12 h-12 dark:flex"
title="{{ i18n "footer.light_appearance" }}"
>
{{ partial "icon.html" "sun" }}

View File

@ -6,9 +6,12 @@
</div>
{{/* Main menu */}}
{{ if or .Site.Menus.main (.Site.Params.enableSearch | default false) }}
<ul class="flex list-none flex-col text-end sm:flex-row">
<ul class="flex flex-col list-none text-end sm:flex-row">
{{ if .Site.Menus.main }}
{{ range .Site.Menus.main }}
{{ if and (eq .Params.action "locale") (and (not page.IsTranslated) (not site.IsMultiLingual)) }}
{{ continue }}
{{ end }}
<li class="group mb-1 sm:mb-0 sm:me-7 sm:last:me-0.5">
{{ if eq .Params.action "search" }}
{{ $.Scratch.Add "searchCount" 1 }}
@ -19,7 +22,7 @@
>
{{ with .Params.icon | default "search" }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -39,7 +42,7 @@
aria-label="appearance switcher"
>
<span
class="group-dark:hover:text-primary-400 inline transition-colors group-hover:text-primary-600 dark:hidden"
class="inline transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:hidden"
title="{{ i18n "footer.dark_appearance" }}"
>
{{ with .Params.icon | default "moon" }}
@ -53,7 +56,7 @@
{{ end }}
</span>
<span
class="group-dark:hover:text-primary-400 hidden transition-colors group-hover:text-primary-600 dark:inline"
class="hidden transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:inline"
title="{{ i18n "footer.light_appearance" }}"
>
{{ with .Params.icon | default "sun" }}
@ -77,7 +80,7 @@
{{ with .Params.target }}target="{{ . }}"{{ end }}
>{{ with .Params.icon }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -92,10 +95,10 @@
</li>
{{ end }}
{{ if and ($.Site.Params.enableSearch | default false) (eq ($.Scratch.Get "searchCount") 0) }}
<li class="group mb-1 sm:mb-0 sm:me-7 sm:last:me-0">
<li class="mb-1 group sm:mb-0 sm:me-7 sm:last:me-0">
<button id="search-button-m0" title="{{ i18n "search.open_button_title" }}">
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{ partial "icon.html" "search" }}
</span>

View File

@ -13,10 +13,10 @@
</div>
<div
id="menu-wrapper"
class="invisible fixed inset-0 z-30 m-auto h-full w-full cursor-default overflow-auto bg-neutral-100/50 opacity-0 backdrop-blur-sm transition-opacity dark:bg-neutral-900/50"
class="fixed inset-0 z-30 invisible w-full h-full m-auto overflow-auto transition-opacity opacity-0 cursor-default bg-neutral-100/50 backdrop-blur-sm dark:bg-neutral-900/50"
>
<ul
class="mx-auto flex w-full max-w-7xl list-none flex-col overflow-visible px-6 py-6 text-end sm:px-14 sm:py-10 sm:pt-10 md:px-24 lg:px-32"
class="flex flex-col w-full px-6 py-6 mx-auto overflow-visible list-none max-w-7xl text-end sm:px-14 sm:py-10 sm:pt-10 md:px-24 lg:px-32"
>
<li class="mb-1">
<span class="cursor-pointer hover:text-primary-600 dark:hover:text-primary-400"
@ -25,7 +25,10 @@
</li>
{{ if .Site.Menus.main }}
{{ range .Site.Menus.main }}
<li class="group mb-1">
{{ if and (eq .Params.action "locale") (and (not page.IsTranslated) (not site.IsMultiLingual)) }}
{{ continue }}
{{ end }}
<li class="mb-1 group">
{{ if eq .Params.action "search" }}
{{ $.Scratch.Add "searchCount" 1 }}
{{ if $.Site.Params.enableSearch | default false }}
@ -35,7 +38,7 @@
>
{{ with .Params.icon | default "search" }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -55,7 +58,7 @@
aria-label="appearance switcher"
>
<span
class="group-dark:hover:text-primary-400 inline transition-colors group-hover:text-primary-600 dark:hidden"
class="inline transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:hidden"
title="{{ i18n "footer.dark_appearance" }}"
>
{{ with .Params.icon | default "moon" }}
@ -69,7 +72,7 @@
{{ end }}
</span>
<span
class="group-dark:hover:text-primary-400 hidden transition-colors group-hover:text-primary-600 dark:inline"
class="hidden transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:inline"
title="{{ i18n "footer.light_appearance" }}"
>
{{ with .Params.icon | default "sun" }}
@ -93,7 +96,7 @@
{{ with .Params.target }}target="{{ . }}"{{ end }}
>{{ with .Params.icon }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -108,10 +111,10 @@
</li>
{{ end }}
{{ if and ($.Site.Params.enableSearch | default false) (eq ($.Scratch.Get "searchCount") 0) }}
<li class="group mb-1">
<li class="mb-1 group">
<button id="search-button-m0" title="{{ i18n "search.open_button_title" }}">
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{ partial "icon.html" "search" }}
</span>

View File

@ -13,10 +13,10 @@
</div>
<div
id="menu-wrapper"
class="invisible fixed inset-0 z-30 m-auto h-full w-full cursor-default overflow-auto bg-neutral-100/50 opacity-0 backdrop-blur-sm transition-opacity dark:bg-neutral-900/50"
class="fixed inset-0 z-30 invisible w-full h-full m-auto overflow-auto transition-opacity opacity-0 cursor-default bg-neutral-100/50 backdrop-blur-sm dark:bg-neutral-900/50"
>
<ul
class="mx-auto flex w-full max-w-7xl list-none flex-col overflow-visible px-6 py-6 text-end sm:px-14 sm:py-10 sm:pt-10 md:px-24 lg:px-32"
class="flex flex-col w-full px-6 py-6 mx-auto overflow-visible list-none max-w-7xl text-end sm:px-14 sm:py-10 sm:pt-10 md:px-24 lg:px-32"
>
<li class="mb-1">
<span class="cursor-pointer hover:text-primary-600 dark:hover:text-primary-400"
@ -25,7 +25,10 @@
</li>
{{ if .Site.Menus.main }}
{{ range .Site.Menus.main }}
<li class="group mb-1">
{{ if and (eq .Params.action "locale") (and (not page.IsTranslated) (not site.IsMultiLingual)) }}
{{ continue }}
{{ end }}
<li class="mb-1 group">
{{ if eq .Params.action "search" }}
{{ $.Scratch.Add "searchCount" 1 }}
{{ if $.Site.Params.enableSearch | default false }}
@ -35,7 +38,7 @@
>
{{ with .Params.icon | default "search" }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -55,7 +58,7 @@
aria-label="appearance switcher"
>
<span
class="group-dark:hover:text-primary-400 inline transition-colors group-hover:text-primary-600 dark:hidden"
class="inline transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:hidden"
title="{{ i18n "footer.dark_appearance" }}"
>
{{ with .Params.icon | default "moon" }}
@ -69,7 +72,7 @@
{{ end }}
</span>
<span
class="group-dark:hover:text-primary-400 hidden transition-colors group-hover:text-primary-600 dark:inline"
class="hidden transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:inline"
title="{{ i18n "footer.light_appearance" }}"
>
{{ with .Params.icon | default "sun" }}
@ -93,7 +96,7 @@
{{ with .Params.target }}target="{{ . }}"{{ end }}
>{{ with .Params.icon }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -108,10 +111,10 @@
</li>
{{ end }}
{{ if and ($.Site.Params.enableSearch | default false) (eq ($.Scratch.Get "searchCount") 0) }}
<li class="group mb-1">
<li class="mb-1 group">
<button id="search-button-m0" title="{{ i18n "search.open_button_title" }}">
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{ partial "icon.html" "search" }}
</span>
@ -123,10 +126,13 @@
</div>
</label>
{{/* Basic menu */}}
<ul class="hidden list-none flex-row text-end sm:flex">
<ul class="flex-row hidden list-none text-end sm:flex">
{{ if .Site.Menus.main }}
{{ range .Site.Menus.main }}
<li class="group mb-1 sm:mb-0 sm:me-7 sm:last:me-0">
{{ if and (eq .Params.action "locale") (and (not page.IsTranslated) (not site.IsMultiLingual)) }}
{{ continue }}
{{ end }}
<li class="mb-1 group sm:mb-0 sm:me-7 sm:last:me-0">
{{ if eq .Params.action "search" }}
{{ $.Scratch.Add "searchCount" 1 }}
{{ if $.Site.Params.enableSearch | default false }}
@ -136,7 +142,7 @@
>
{{ with .Params.icon | default "search" }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -156,7 +162,7 @@
aria-label="appearance switcher"
>
<span
class="group-dark:hover:text-primary-400 inline transition-colors group-hover:text-primary-600 dark:hidden"
class="inline transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:hidden"
title="{{ i18n "footer.dark_appearance" }}"
>
{{ with .Params.icon | default "moon" }}
@ -170,7 +176,7 @@
{{ end }}
</span>
<span
class="group-dark:hover:text-primary-400 hidden transition-colors group-hover:text-primary-600 dark:inline"
class="hidden transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600 dark:inline"
title="{{ i18n "footer.light_appearance" }}"
>
{{ with .Params.icon | default "sun" }}
@ -194,7 +200,7 @@
{{ with .Params.target }}target="{{ . }}"{{ end }}
>{{ with .Params.icon }}
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{- partial "icon.html" . -}}
</span>
@ -209,10 +215,10 @@
</li>
{{ end }}
{{ if and ($.Site.Params.enableSearch | default false) (eq ($.Scratch.Get "searchCount") 0) }}
<li class="group mb-1 sm:mb-0 sm:me-7 sm:last:me-0">
<li class="mb-1 group sm:mb-0 sm:me-7 sm:last:me-0">
<button id="search-button-m1" title="{{ i18n "search.open_button_title" }}">
<span
class="group-dark:hover:text-primary-400 transition-colors group-hover:text-primary-600"
class="transition-colors group-dark:hover:text-primary-400 group-hover:text-primary-600"
>
{{ partial "icon.html" "search" }}
</span>