From e5e291a0f6ac6dc5b51ba3f26ce19983af960a79 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Wed, 7 Aug 2024 11:50:19 -0400 Subject: [PATCH 1/4] Adds a warning when truncating menu list in sidebar-tree.html --- layouts/partials/sidebar-tree.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/layouts/partials/sidebar-tree.html b/layouts/partials/sidebar-tree.html index 2ce0c56373..3d3b2b27b8 100644 --- a/layouts/partials/sidebar-tree.html +++ b/layouts/partials/sidebar-tree.html @@ -50,6 +50,7 @@ {{ $mid := printf "m-%s" ($s.RelPermalink | anchorize) -}} {{ $pages_tmp := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true -}} {{ $pages := $pages_tmp | first $sidebarMenuTruncate -}} +{{ if ge (len $pages_tmp) $sidebarMenuTruncate -}}{{ warnf "Warning: Some ToC entries won't be displayed on %s. Increase [params.ui.sidebar_menu_truncate] in your config file to avoid that. " $s -}}{{ end -}} {{ $withChild := gt (len $pages) 0 -}} {{ $manualLink := cond (isset $s.Params "manuallink") $s.Params.manualLink ( cond (isset $s.Params "manuallinkrelref") (relref $s $s.Params.manualLinkRelref) $s.RelPermalink) -}} {{ $manualLinkTitle := cond (isset $s.Params "manuallinktitle") $s.Params.manualLinkTitle $s.Title -}} @@ -71,4 +72,4 @@ {{- end }} -{{- end }} \ No newline at end of file +{{- end }} From 560ac88f35409ef3ddb94d4edc879e23c4b5cbb2 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Wed, 7 Aug 2024 12:01:48 -0400 Subject: [PATCH 2/4] Improve warning msg, clean up whitespace excess --- layouts/partials/sidebar-tree.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/layouts/partials/sidebar-tree.html b/layouts/partials/sidebar-tree.html index 3d3b2b27b8..ab80b2a201 100644 --- a/layouts/partials/sidebar-tree.html +++ b/layouts/partials/sidebar-tree.html @@ -50,7 +50,11 @@ {{ $mid := printf "m-%s" ($s.RelPermalink | anchorize) -}} {{ $pages_tmp := where (union $s.Pages $s.Sections).ByWeight ".Params.toc_hide" "!=" true -}} {{ $pages := $pages_tmp | first $sidebarMenuTruncate -}} -{{ if ge (len $pages_tmp) $sidebarMenuTruncate -}}{{ warnf "Warning: Some ToC entries won't be displayed on %s. Increase [params.ui.sidebar_menu_truncate] in your config file to avoid that. " $s -}}{{ end -}} +{{ $truncatedEntryCount := sub (len $pages_tmp) $sidebarMenuTruncate -}} +{{ if gt $truncatedEntryCount 0 -}} + {{ warnf "WARNING: %d sidebar entries have been truncated. To avoid this, increase `params.ui.sidebar_menu_truncate` to at least %d (from %d) in your config file. Section: %s" + $truncatedEntryCount (len $pages_tmp) $sidebarMenuTruncate $s.Path -}} +{{ end -}} {{ $withChild := gt (len $pages) 0 -}} {{ $manualLink := cond (isset $s.Params "manuallink") $s.Params.manualLink ( cond (isset $s.Params "manuallinkrelref") (relref $s $s.Params.manualLinkRelref) $s.RelPermalink) -}} {{ $manualLinkTitle := cond (isset $s.Params "manuallinktitle") $s.Params.manualLinkTitle $s.Title -}} @@ -72,4 +76,4 @@ {{- end }} -{{- end }} +{{- end -}} From 4f4bdb7b8410851a48229489a5674db11472c1e8 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Wed, 7 Aug 2024 12:12:54 -0400 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 789593d96b..122b3756ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ For the full list of changes, see the [0.x.y] release notes. base support for RTL][bs-rtl]. - The URL to your project's contribution guidelines is configurable. For details, see [Adding a community page]. +- A warning is now output when a section's sidebar entries are truncated because + there are more than [params.ui.sidebar_menu_truncate] section entries. **Other changes**: TBC @@ -39,6 +41,8 @@ For the full list of changes, see the [0.x.y] release notes. [bs-rtl]: https://getbootstrap.com/docs/5.3/getting-started/rtl/ [Adding a community page]: https://www.docsy.dev/docs/adding-content/content/#adding-a-community-page +[params.ui.sidebar_menu_truncate]: + https://www.docsy.dev/docs/adding-content/navigation/#section-menu-options ## 0.10.0 From 85a4d34541fd9174d67eb7baac30b06d847aa1b6 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Wed, 7 Aug 2024 12:44:11 -0400 Subject: [PATCH 4/4] Double sidebar_menu_truncate limit --- layouts/partials/sidebar-tree.html | 2 +- userguide/content/en/docs/adding-content/navigation.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/sidebar-tree.html b/layouts/partials/sidebar-tree.html index ab80b2a201..ae374eb7c3 100644 --- a/layouts/partials/sidebar-tree.html +++ b/layouts/partials/sidebar-tree.html @@ -30,7 +30,7 @@ {{ $navRoot := cond (and (ne .Params.toc_root true) (eq .Site.Home.Type "docs")) .Site.Home .FirstSection -}} {{ $ulNr := 0 -}} {{ $ulShow := .Site.Params.ui.ul_show | default 1 -}} - {{ $sidebarMenuTruncate := .Site.Params.ui.sidebar_menu_truncate | default 50 -}} + {{ $sidebarMenuTruncate := .Site.Params.ui.sidebar_menu_truncate | default 100 -}}
    {{ template "section-tree-nav-section" (dict "page" . "section" $navRoot "shouldDelayActive" $shouldDelayActive "sidebarMenuTruncate" $sidebarMenuTruncate "ulNr" $ulNr "ulShow" (add $ulShow 1)) }}
diff --git a/userguide/content/en/docs/adding-content/navigation.md b/userguide/content/en/docs/adding-content/navigation.md index 31e79ade8f..297b29a521 100644 --- a/userguide/content/en/docs/adding-content/navigation.md +++ b/userguide/content/en/docs/adding-content/navigation.md @@ -222,7 +222,7 @@ By default, the section menu shows the current section fully expanded all the wa With the compact menu (`.ui.sidebar_menu_compact = true`), only the current page's ancestors, siblings and direct descendants are shown. You can use the optional parameter `.ui.ul_show` to set a desired menu depth to always be visible. For example, with `.ui.ul_show = 1` the first menu level is always displayed. -The number of sidebar entries shown per section can be configured using the `.ui.sidebar_menu_truncate` parameter (default: 50). +The number of sidebar entries shown per section can be configured using the `.ui.sidebar_menu_truncate` parameter (default: 100). As well as the completely expanded and compact menu options, you can also create a foldable menu by setting the site parameter `ui.sidebar_menu_foldable = true` in `hugo.toml`. The foldable menu lets users expand and collapse menu sections by toggling arrow icons beside the section parents in the menu.