From babd536f4083a944b1d8b6b205029e4d478f3ddb Mon Sep 17 00:00:00 2001 From: Cam Date: Tue, 23 Sep 2025 20:02:31 +0000 Subject: [PATCH 01/34] Finally got the menu working --- layouts/partials/docs/main-nav.html | 29 ++- layouts/partials/docs/menu.html | 262 +++++++++++++++++++++------- layouts/partials/docs/search.html | 4 +- 3 files changed, 225 insertions(+), 70 deletions(-) diff --git a/layouts/partials/docs/main-nav.html b/layouts/partials/docs/main-nav.html index daaf408fae12..4475363ca620 100644 --- a/layouts/partials/docs/main-nav.html +++ b/layouts/partials/docs/main-nav.html @@ -29,8 +29,8 @@ {{ $sidenav_selected = "active" }} {{ end }}
- {{ $toc_name }} - {{ if and ($toc_section_link) (ne $toc_name "Get started") }} + {{ $toc_name }} + {{ if $toc_section_link }}
@@ -41,13 +41,34 @@
- {{ template "toc" (dict "page" $toc_page "menu" $toc_menu) }} + {{ template "toc" (dict "page" $toc_page "menu" $toc_menu "section_link" $toc_section_link) }}
{{ end }} {{ end }} {{ define "toc" }} {{ $page := .page }} + {{ $section_link := .section_link }} + + {{/* Add Overview link as first item if section_link exists */}} + {{ if $section_link }} + {{ $sidenav_selected := "" }} + {{ if eq $page.RelPermalink $section_link }} + {{ $sidenav_selected = "active" }} + {{ end }} + + {{ end }} {{ range .menu }} {{/* Note that we skip "Overview" pages, since they are linked to from above */}} @@ -94,7 +115,7 @@ {{ if .HasChildren }}
- {{ template "toc" (dict "page" $page "menu" .Children) }} + {{ template "toc" (dict "page" $page "menu" .Children "section_link" nil) }}
{{ end }} diff --git a/layouts/partials/docs/menu.html b/layouts/partials/docs/menu.html index 3462e88cd0b0..e07631657014 100644 --- a/layouts/partials/docs/menu.html +++ b/layouts/partials/docs/menu.html @@ -1,81 +1,215 @@ {{- $page := .page }} -{{- $menuID := .menu }} -{{/* If a valid menu choice was passed in, use that. Otherwise, try to derive -one from the current path. If that doesn't work, don't show a menu. (TODO: Would -it be helpful to be able to set the menu somehow in the frontmatter?) */}} +{{/* Detect current section for auto-expansion */}} +{{ $currentSection := "home" }} +{{ if hasPrefix $page.Path "/docs/iac" }} + {{ $currentSection = "iac" }} +{{ else if hasPrefix $page.Path "/docs/esc" }} + {{ $currentSection = "esc" }} +{{ else if hasPrefix $page.Path "/docs/idp" }} + {{ $currentSection = "idp" }} +{{ else if hasPrefix $page.Path "/docs/pulumi-cloud" }} + {{ $currentSection = "cloud" }} +{{ else if hasPrefix $page.Path "/docs/insights" }} + {{ $currentSection = "insights" }} +{{ else if hasPrefix $page.Path "/registry" }} + {{ $currentSection = "packages" }} +{{ else if hasPrefix $page.Path "/tutorials" }} + {{ $currentSection = "tutorials" }} +{{ end }} -{{ $validMenus := slice "iac" "esc" "idp" "cloud" "insights"}} + {{- define "partials/inline/menu/walk.html" }} {{- $page := .page }} - {{- $rootMenuID := (printf "%s-home" .rootMenuID) }} + {{- $rootMenuID := .rootMenuID }} {{- range .menuEntries }} - {{- $attrs := dict "href" .URL }} - {{- if $page.IsMenuCurrent .Menu . }} - {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }} - {{- else if $page.HasMenuCurrent .Menu .}} - {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }} - {{- end }} - {{- $name := .Name }} - {{- with .Identifier }} - {{- with T . }} - {{- $name = . }} + {{/* Skip Overview pages since we add them manually */}} + {{/* Skip root home items that we've already created manually */}} + {{- if and (ne .Name "Overview") (ne .Identifier $rootMenuID) }} + {{- $attrs := dict "href" .URL }} + {{- if $page.IsMenuCurrent .Menu . }} + {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }} + {{- else if $page.HasMenuCurrent .Menu .}} + {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }} {{- end }} - {{- end }} - - + + {{/* Store the current menu item before entering Children context */}} + {{- $currentMenuItem := . }} + + + {{- end }} {{- end }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/docs/search.html b/layouts/partials/docs/search.html index b58e91d10316..0e43cbb9e7d1 100644 --- a/layouts/partials/docs/search.html +++ b/layouts/partials/docs/search.html @@ -1,7 +1,7 @@