Skip to content

Conversation

@AntoninPvr
Copy link
Contributor

@AntoninPvr AntoninPvr commented Nov 25, 2025

Added detection in the sidebar partial for cases where the sidebar is also used as a navbar, i.e., in mobile view.

This workaround use "IsHome" from context. It fix #240 (comment) and partialy #265 (comment)

This workaround isn’t elegant. It would be better to create a new partial, side-navbar.html, that relies on sidebar.html. This would allow crawling through menu.main in hugo.yaml and discovering the subfolders under each section based on each menu path. (Handling nested menus is still an open question.) This refactor will allow to easily fix #497 (comment), #831 (comment) and #449 (comment) by getting weight and name from hugo.yaml

@netlify
Copy link

netlify bot commented Nov 25, 2025

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit 1f58b0f
🔍 Latest deploy log https://app.netlify.com/projects/hugo-hextra/deploys/69250752c5c8e50008bfd076
😎 Deploy Preview https://deploy-preview-883--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI review requested due to automatic review settings January 19, 2026 22:28
@netlify
Copy link

netlify bot commented Jan 19, 2026

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit 0f9aae6
🔍 Latest deploy log https://app.netlify.com/projects/hugo-hextra/deploys/696eb85f21118a000802e869
😎 Deploy Preview https://deploy-preview-883--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the mobile navbar to properly respect the menu.main configuration in hugo.yaml. Previously, the sidebar when used as a mobile navbar would display all pages and sections. Now it filters items to only show those defined in the main menu configuration.

Changes:

  • Added conditional filtering logic in the sidebar partial that detects when the sidebar is used as a navbar (via IsHome check)
  • Items are now filtered against menu.main paths when rendering the mobile view
  • Refactored from with statement to direct variable assignment to support the new filtering logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{{- $items = $itemsCandidates -}}
{{- end -}}

{{- $items = where $items "Params.sidebar.exclude" "!=" true -}}
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation here is inconsistent with the rest of the code block. This line has 4 spaces of indentation, but should have 2 spaces to match the indentation level of lines 81-82 and other statements at the same nesting level.

Suggested change
{{- $items = where $items "Params.sidebar.exclude" "!=" true -}}
{{- $items = where $items "Params.sidebar.exclude" "!=" true -}}

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +100
{{- if .context.IsHome -}}
{{- $allowedPaths := slice -}}
{{- range site.Menus.main -}}
{{- with .Page -}}
{{- $allowedPaths = $allowedPaths | append .Path -}}
{{- end -}}
{{- end -}}

{{- range $itemsCandidates -}}
{{- if in $allowedPaths .Path -}}
{{- $items = $items | append . -}}
{{- end -}}
{{- end -}}

{{- else -}}
{{- $items = $itemsCandidates -}}
{{- end -}}
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This complex filtering logic would benefit from an inline comment explaining its purpose. Consider adding a comment like "Filter items to only show pages that are in the main menu when rendering the mobile navbar" to help future maintainers understand why this conditional filtering is needed.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The mobile nav items are different than the normal nav items

2 participants