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 }} -
+
{{- $rootObject := site.Home }} {{- if $config.pageRef }} {{- $rootObject = partial "_relearn/refObject.gotmpl" (dict "page" $currentNode "objectRef" $config.pageRef) }} @@ -87,21 +87,24 @@ {{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" $config.pageRef "page" $currentNode "param" "link" "msg" $msg) }} {{- end }} {{- end }} + {{- $title := "" }} + {{- if and $rootObject (not ($config.disableTitle | default true)) }} + {{- $title = $rootObject.Params.menuTitle | default (T (print $config.identifier "-menuTitle")) }} + {{- end }} + {{- $entries := "" }} + {{- with $rootObject }} + {{- $entries = partialCached "_relearn/pages.gotmpl" (dict "page" .) .Path }} + {{- end }} + {{- with and $entries $title }} + + {{- end }} + {{- $classes := "space " }} + {{- if ($config.main | default true) }} + {{- $classes = "enlarge morespace " }} + {{- end }} +
- {{- end }} {{- end }} {{- define "partials/inline/page-walker" }} {{- $currentNode := .currentnode }} @@ -223,38 +226,39 @@ {{- $currentNode := .currentnode }} {{- $config := .config }} {{- $showvisitedlinks := .showvisitedlinks }} - {{- with .entries }} -
- {{- $topLevelMenu := "" }} - {{- $topLevelObject := "" }} - {{- $entries := . }} - {{- with and (eq (len $entries) 1) (index $entries 0) }} - {{- if and (not .PageRef) (not .URL) }} - {{- /* because in Hugo menus can not have parameter but menu entries can, - we can flag a single top level menu entry as a container; this container - entry carrys just meta information and parameter, uses its children - to build the "real" menu, and has no own `url` or `pageRef` */}} - {{- $topLevelMenu = . }} - {{- $topLevelObject = partial "_relearn/menuObject.gotmpl" (dict "page" $currentNode "menu" $topLevelMenu) }} - {{- $entries = .Children }} - {{- end }} +
+ {{- $topLevelMenu := "" }} + {{- $topLevelObject := "" }} + {{- $entries := .entries | default "" }} + {{- with and $entries (eq (len $entries) 1) (index $entries 0) }} + {{- if and (not .PageRef) (not .URL) }} + {{- /* because in Hugo menus can not have parameter but menu entries can, + we can flag a single top level menu entry as a container; this container + entry carrys just meta information and parameter, uses its children + to build the "real" menu, and has no own `url` or `pageRef` */}} + {{- $topLevelMenu = . }} + {{- $topLevelObject = partial "_relearn/menuObject.gotmpl" (dict "page" $currentNode "menu" $topLevelMenu) }} + {{- $entries = .Children }} {{- end }} - {{- $title := "" }} - {{- if not ($config.disableTitle | default false) }} - {{- if $topLevelMenu }} - {{- $title = partial "_relearn/menuTitle.gotmpl" (dict "page" $currentNode "menu" $topLevelMenu) }} - {{- else }} - {{- $title = T (print $config.identifier "-menuTitle") }} - {{- end }} + {{- end }} + {{- $title := "" }} + {{- if not ($config.disableTitle | default false) }} + {{- if $topLevelMenu }} + {{- $title = partial "_relearn/menuTitle.gotmpl" (dict "page" $currentNode "menu" $topLevelMenu) }} + {{- else }} + {{- $title = T (print $config.identifier "-menuTitle") }} {{- end }} - {{- with $title }} + {{- end }} + {{- with and $entries $title }} - {{- end }} - {{- $classes := "space " }} - {{- if ($config.main | default false) }} - {{- $classes = "enlarge morespace " }} - {{- end }} + {{- end }} + {{- $classes := "space " }} + {{- if ($config.main | default false) }} + {{- $classes = "enlarge morespace " }} + {{- end }}
    + {{- with $entries }} + {{- $entries := . }} {{- $root := or $topLevelMenu site }} {{- $defaultAlwaysopen := site.Params.alwaysopen | default false }} {{- range $entries }} @@ -270,14 +274,14 @@ {{- partialCached "partials/inline/menu-walker" (dict "menu" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen "isSelf" $isSubSelf "isAncestor" $isSubAncestor "isHidden" $isSubHidden "root" $root) $id }} {{- end }} {{- end }} -
-
{{- else }} - {{- if not (isset $config "entries") }} + {{- if and (not (isset $config "entries")) (ne $config.identifier "shortcuts") }} {{- $msg := printf "config option 'identifier' for 'sidebarmenus' %q is not a menu" $config.identifier }} {{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" $config.pageRef "page" $currentNode "param" "link" "msg" $msg "applyErrorIgnore" false) }} {{- end }} {{- end }} + +
{{- end }} {{- define "partials/inline/menu-walker" }} {{- $currentNode := .currentnode }} @@ -378,19 +382,17 @@ {{- define "partials/inline/custom-list" }} {{- $currentNode := .currentnode }} {{- $config := .config }} - {{- with .elements }} -
- {{- $classes := "" }} - {{- if ($config.main | default false) }} - {{- $classes = "space" }} - {{- end }} +
+ {{- $classes := "" }} + {{- if ($config.main | default false) }} + {{- $classes = "space" }} + {{- end }}
    - {{- range . }} - {{- partial (printf "sidebar/element/%s.html" .type) (dict "page" $currentNode "config" $config "element" .) }} - {{- end }} + {{- range .elements }} + {{- partial (printf "sidebar/element/%s.html" .type) (dict "page" $currentNode "config" $config "element" .) }} + {{- end }}
- {{- end }} {{- end }} {{- define "partials/inline/divider" }} diff --git a/layouts/partials/sidebar/element/historyclearer.html b/layouts/partials/sidebar/element/historyclearer.html index 6cb6559954..bd1a39e669 100644 --- a/layouts/partials/sidebar/element/historyclearer.html +++ b/layouts/partials/sidebar/element/historyclearer.html @@ -1,7 +1,9 @@ -{{- $icon := .element.icon | default "history" }} -{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} - {{- $icon = printf "fa-fw fas fa-%s" $icon }} -{{- end }} +{{- $showvisitedlinks := site.Params.showVisitedLinks }} +{{- if $showvisitedlinks }} + {{- $icon := .element.icon | default "history" }} + {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} + {{- $icon = printf "fa-fw fas fa-%s" $icon }} + {{- end }}
  • - \ No newline at end of file + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/sidebar/element/languageswitcher.html b/layouts/partials/sidebar/element/languageswitcher.html index f7d9d87b6a..2687ea3401 100644 --- a/layouts/partials/sidebar/element/languageswitcher.html +++ b/layouts/partials/sidebar/element/languageswitcher.html @@ -1,7 +1,10 @@ -{{- $icon := .element.icon | default "language" }} -{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} - {{- $icon = printf "fa-fw fas fa-%s" $icon }} -{{- end }} +{{- $siteLanguages := site.Languages }} +{{- $showlangswitch := and hugo.IsMultilingual (not site.Params.disableLanguageSwitchingButton) (gt (int (len $siteLanguages)) 1) }} +{{- if $showlangswitch }} + {{- $icon := .element.icon | default "language" }} + {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} + {{- $icon = printf "fa-fw fas fa-%s" $icon }} + {{- end }}
  • - \ 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 }}
  • -
  • \ No newline at end of file + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/sidebar/element/versionswitcher.html b/layouts/partials/sidebar/element/versionswitcher.html index d49a3e9244..c042f74bbd 100644 --- a/layouts/partials/sidebar/element/versionswitcher.html +++ b/layouts/partials/sidebar/element/versionswitcher.html @@ -1,9 +1,10 @@ {{- $versions := partialCached "_relearn/siteVersions.gotmpl" .page }} -{{- $pageVersion := site.Params.version | default "" }} -{{- $icon := .element.icon | default "code-branch" }} -{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} - {{- $icon = printf "fa-fw fas fa-%s" $icon }} -{{- end }} +{{- if $versions }} + {{- $pageVersion := site.Params.version | default "" }} + {{- $icon := .element.icon | default "code-branch" }} + {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} + {{- $icon = printf "fa-fw fas fa-%s" $icon }} + {{- end }}
  • -
  • \ No newline at end of file + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/version.txt b/layouts/partials/version.txt index eebdf44e63..89a198bd18 100644 --- a/layouts/partials/version.txt +++ b/layouts/partials/version.txt @@ -1 +1 @@ -7.5.0+e2a1704c3c230050d3777be3bae36285a7fa0d8e \ No newline at end of file +7.5.0+fae610dae90549aaac0ba396bd6f2a884ba65702 \ No newline at end of file