diff --git a/assets/css/theme.css b/assets/css/theme.css index f62f8de546..96d83ed375 100644 --- a/assets/css/theme.css +++ b/assets/css/theme.css @@ -350,6 +350,41 @@ a:focus, margin-top: 0; } +/* visibility for sidebarheader is tricky; first and last divider may have different colors +than the ones in between, so they need to have privileged visibility; order is: +- last +- first +- in between +*/ +#R-sidebar .R-sidebarmenu:not(:has(> ul > *)) { + /* hide all empty menus */ + display: none; +} +#R-sidebar .R-menu-divider:not(:has(+ .R-sidebarmenu > ul > *)) hr { + /* hide all upper hrs if the following menu has no entries, + this is common for all menu regardless of header, body or footer */ + display: none; +} +#R-homelinks .R-menu-divider:first-child:not(:has(+ .R-sidebarmenu > ul > *)):has(~ .R-sidebarmenu > ul > *) hr { + /* in case if the first menu is empty and we have some other menus to follow, we have + to show the first divider because of different coloring */ + display: revert; +} +#R-homelinks .R-menu-divider:first-child + .R-sidebarmenu:not(:has(> ul > *)) ~ .R-menu-divider:has(+ .R-sidebarmenu > ul > *) hr { + /* in case if the first menu is empty and we have some other menus to follow, we have + to hide the first following menus divider because of different coloring; + this selector selects all following menus, so we have to write a follow up + rule to remove that effect on all but the first */ + display: none; +} +#R-sidebar #R-homelinks .R-menu-divider:has(+ .R-sidebarmenu > ul > *) ~ .R-menu-divider:has(+ .R-sidebarmenu > ul > *) hr { + /* the mentioned follow up rule from above */ + display: revert; +} +#R-sidebar #R-homelinks .R-menu-divider:last-child hr { + display: revert; +} + #R-content-wrapper hr { border-color: var(--INTERNAL-MENU-SECTION-SEPARATOR-color); } diff --git a/docs/content/configuration/sidebar/menus/_index.en.md b/docs/content/configuration/sidebar/menus/_index.en.md index 544ab2916b..416a4e8de2 100644 --- a/docs/content/configuration/sidebar/menus/_index.en.md +++ b/docs/content/configuration/sidebar/menus/_index.en.md @@ -226,9 +226,10 @@ As these options are arrays, you can define as many menus, as you like in each a If you don't set these options in your `hugo.toml`, the theme defaults as follows: - `sidebarheadermenus`: + - a divider to separate from the logo (depending on the color configuration of the theme variant) if any of the following is configured - a home button if [configured](configuration/sidebar/headerfooter#home-button-configuration), if you redefine this, use a Hugo menu and a `type=menu` to replicate this - the version switcher if versioning is [configured](configuration/sitemanagement/versioning) - - a divider to separate from the `sidebarmenus` (depending on the configuration of the theme variant) + - a divider to separate from the `sidebarmenus` (depending on the color configuration of the theme variant) - `sidebarmenus`: - the main page menu based on your [content structure](authoring/structure) - the `shortcuts` menu including the title if [configured](#predefined-shortcuts-menu) @@ -238,8 +239,6 @@ If you don't set these options in your `hugo.toml`, the theme defaults as follow - the variant switcher if multiple variants are [configured](configuration/branding/colors/#multiple-variants) - the history clearer if you [configured](configuration/sidebar/headerfooter#history) to mark visited pages -However, if you decide to overwrite these options, the configuration for those features will not be taken into account anymore. For example, if you want to reorder the `sidebarfootermenus` by setting - {{< multiconfig section=params >}} sidebarfootermenus = [ { type = 'divider' }, diff --git a/layouts/partials/_relearn/defaultSidebar.gotmpl b/layouts/partials/_relearn/defaultSidebar.gotmpl index f44080d43a..2609b02045 100644 --- a/layouts/partials/_relearn/defaultSidebar.gotmpl +++ b/layouts/partials/_relearn/defaultSidebar.gotmpl @@ -1,9 +1,11 @@ -{{- $defaultmenuconfigs := slice +{{- $defaultmenuconfigs := slice }} + +{{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "page" "identifier" "home") }} -{{- if index site.Menus "shortcuts" }} - {{- $defaultmenuconfigs = $defaultmenuconfigs | append - (dict "type" "menu" "identifier" "shortcuts" "disableTitle" site.Params.disableShortcutsTitle) - }} -{{- end }} + +{{- $defaultmenuconfigs = $defaultmenuconfigs | append + (dict "type" "menu" "identifier" "shortcuts" "disableTitle" site.Params.disableShortcutsTitle) +}} + {{- return $defaultmenuconfigs }} \ No newline at end of file diff --git a/layouts/partials/_relearn/defaultSidebarFooter.gotmpl b/layouts/partials/_relearn/defaultSidebarFooter.gotmpl index 3cf36f1473..d2b60738f4 100644 --- a/layouts/partials/_relearn/defaultSidebarFooter.gotmpl +++ b/layouts/partials/_relearn/defaultSidebarFooter.gotmpl @@ -1,27 +1,13 @@ {{- $defaultmenuconfigs := slice }} {{- $defaultconfigelements := slice }} -{{- $siteLanguages := site.Languages }} -{{- $showlangswitch := and hugo.IsMultilingual (not site.Params.disableLanguageSwitchingButton) (gt (int (len $siteLanguages)) 1) }} -{{- if $showlangswitch }} - {{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "languageswitcher") }} -{{- end }} +{{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "divider") }} -{{- $themevariants := partialCached "_relearn/themeVariants.gotmpl" . }} -{{- $showvariantswitch := gt (int (len $themevariants)) 1 }} -{{- if $showvariantswitch }} - {{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "variantswitcher") }} -{{- end }} +{{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "languageswitcher") }} +{{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "variantswitcher") }} +{{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "historyclearer") }} +{{- $defaultmenuconfigs = $defaultmenuconfigs | append + (dict "type" "custom" "identifier" "controls" "disableTitle" true "elements" $defaultconfigelements) +}} -{{- $showvisitedlinks := site.Params.showVisitedLinks }} -{{- if $showvisitedlinks }} - {{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "historyclearer") }} -{{- end }} - -{{- if $defaultconfigelements }} - {{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "divider") }} - {{- $defaultmenuconfigs = $defaultmenuconfigs | append - (dict "type" "custom" "identifier" "controls" "disableTitle" true "elements" $defaultconfigelements) - }} -{{- end }} {{- return $defaultmenuconfigs }} \ No newline at end of file diff --git a/layouts/partials/_relearn/defaultSidebarHeader.gotmpl b/layouts/partials/_relearn/defaultSidebarHeader.gotmpl index 3df32581c4..144f2ce6d2 100644 --- a/layouts/partials/_relearn/defaultSidebarHeader.gotmpl +++ b/layouts/partials/_relearn/defaultSidebarHeader.gotmpl @@ -1,6 +1,9 @@ {{- $defaultmenuconfigs := slice }} +{{- $defaultconfigentries := slice }} {{- $defaultconfigelements := slice }} +{{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "divider") }} + {{- if not site.Params.disableLandingPageButton }} {{- if (ne site.Params.landingPageURL nil) }} {{- warnf "UNSUPPORTED usage of 'landingPageURL' config parameter found, remove it and optionally overwrite the `logo.html` partial to provide a link if it should not point to the project's home page; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/4/#4-2-0" }} @@ -16,26 +19,23 @@ {{- $title = T "home-button" }} {{- $pre = ` ` | safeHTML }} {{- end }} - {{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "divider") }} - {{- $defaultmenuconfigs = $defaultmenuconfigs | append - (dict "type" "menu" "identifier" "homelinks" "disableTitle" true "entries" (slice - (dict "Menu" "" "Children" (slice - (dict "Menu" "" "Pre" $pre "Post" $post "Title" $title "PageRef" "/" ) - )) - )) - }} -{{- end }} - -{{- $versions := partialCached "_relearn/siteVersions.gotmpl" . }} -{{- if $versions }} - {{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "versionswitcher") }} -{{- end }} - -{{- if $defaultconfigelements }} - {{- $defaultmenuconfigs = $defaultmenuconfigs | append - (dict "type" "custom" "identifier" "controls" "disableTitle" true "elements" $defaultconfigelements) + {{- $defaultconfigentries = $defaultconfigentries | append + (dict "Menu" "" "Pre" $pre "Post" $post "Title" $title "PageRef" "/" ) }} {{- end }} +{{- $defaultmenuconfigs = $defaultmenuconfigs | append + (dict "type" "menu" "identifier" "homelinks" "disableTitle" true "entries" (slice + (dict "Menu" "" "Children" $defaultconfigentries) + )) +}} {{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "divider") }} + +{{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "versionswitcher") }} +{{- $defaultmenuconfigs = $defaultmenuconfigs | append + (dict "type" "custom" "identifier" "controls" "disableTitle" true "elements" $defaultconfigelements) +}} + +{{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "divider") }} + {{- return $defaultmenuconfigs }} \ No newline at end of file diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index 16a2905ab5..dacb4dfae2 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -78,7 +78,7 @@ {{- $currentNode := .currentnode }} {{- $config := .config }} {{- $showvisitedlinks := .showvisitedlinks }} -
- \ No newline at end of file + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/sidebar/element/variantswitcher.html b/layouts/partials/sidebar/element/variantswitcher.html index 398e8fb8e9..5889b9c66f 100644 --- a/layouts/partials/sidebar/element/variantswitcher.html +++ b/layouts/partials/sidebar/element/variantswitcher.html @@ -1,8 +1,10 @@ -{{- $themevariants := partialCached "_relearn/themeVariants.gotmpl" .page }} -{{- $icon := .element.icon | default "paint-brush" }} -{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} - {{- $icon = printf "fa-fw fas fa-%s" $icon }} -{{- end }} +{{- $themevariants := partialCached "_relearn/themeVariants.gotmpl" . }} +{{- $showvariantswitch := gt (int (len $themevariants)) 1 }} +{{- if $showvariantswitch }} + {{- $icon := .element.icon | default "paint-brush" }} + {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} + {{- $icon = printf "fa-fw fas fa-%s" $icon }} + {{- end }}