& { _lazyKey?: string }
) : item.type === "external" ? (
-
+
) : (
-
+
),
)}
diff --git a/src/components/ui/sidebar/SidebarChildren.astro b/src/components/ui/sidebar/SidebarChildren.astro
index 6612c2a95..399e4b27c 100644
--- a/src/components/ui/sidebar/SidebarChildren.astro
+++ b/src/components/ui/sidebar/SidebarChildren.astro
@@ -13,6 +13,7 @@ interface Props {
const { items } = Astro.props;
type LazyGroup = Extract
& { _lazyKey?: string };
+type IconItem = { icon?: string };
---
@@ -31,9 +32,9 @@ type LazyGroup = Extract & { _lazyKey?: string }
lazyKey={(item as LazyGroup)._lazyKey}
/>
) : item.type === "external" ? (
-
+
) : (
-
+
)}
))}
diff --git a/src/components/ui/sidebar/SidebarGroup.astro b/src/components/ui/sidebar/SidebarGroup.astro
index ecbc56a4d..6361395cf 100644
--- a/src/components/ui/sidebar/SidebarGroup.astro
+++ b/src/components/ui/sidebar/SidebarGroup.astro
@@ -21,6 +21,7 @@ import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@/component
import SidebarChildren from "./SidebarChildren.astro";
import { Badge } from "@/components/ui/badge";
import { withBase } from "@/lib/base";
+import { inlinePublicIcon } from "@/lib/build-icon";
import { LAZY_MIN_CHILDREN } from "@/lib/sidebar-lazy";
import type { SidebarItem, SidebarBadge } from "@cloudflare/nimbus-docs/types";
@@ -69,6 +70,8 @@ function hasActiveDescendant(items: SidebarItem[]): boolean {
}
const hasActive = Boolean(indexIsCurrent) || hasActiveDescendant(items);
+// This is the first-load state only. After hydration, route changes restore
+// the user's exact disclosure state without opening or closing active groups.
const isOpen = Boolean(section || hasActive || collapsed === false || collapsed === undefined);
// Collapsed groups off the active path ship a placeholder instead of their
// subtree; sidebar-lazy.client.ts fetches the prebuilt fragment on expand.
@@ -87,6 +90,7 @@ const iconName = icon && !icon.startsWith("/")
? "ph:network"
: `ph:${icon}`
: undefined;
+const imageIcon = icon?.startsWith("/") ? inlinePublicIcon(icon) : undefined;
---
{icon && (icon.startsWith("/") ? (
-
+
) : (
))}
@@ -139,7 +143,7 @@ const iconName = icon && !icon.startsWith("/")
>
{icon && (icon.startsWith("/") ? (
-
+
) : (
))}
@@ -185,7 +189,7 @@ const iconName = icon && !icon.startsWith("/")
>
{icon && (icon.startsWith("/") ? (
-
+
) : (
))}
diff --git a/src/components/ui/sidebar/SidebarLink.astro b/src/components/ui/sidebar/SidebarLink.astro
index 082efab00..4ec35411e 100644
--- a/src/components/ui/sidebar/SidebarLink.astro
+++ b/src/components/ui/sidebar/SidebarLink.astro
@@ -1,7 +1,9 @@
---
import { cn } from "@/lib/cn";
+import Icon from "@cloudflare/nimbus-docs/components/Icon.astro";
import type { HTMLAttributes } from "astro/types";
import { Badge } from "@/components/ui/badge";
+import { inlinePublicIcon } from "@/lib/build-icon";
import type { SidebarBadge } from "@cloudflare/nimbus-docs/types";
interface Props extends HTMLAttributes<"a"> {
@@ -9,10 +11,19 @@ interface Props extends HTMLAttributes<"a"> {
href: string;
isCurrent?: boolean;
badge?: SidebarBadge;
+ icon?: string;
}
-const { label, href, isCurrent, badge, class: className, ...attrs } = Astro.props;
+const { label, href, isCurrent, badge, icon, class: className, ...attrs } = Astro.props;
const isMethodBadge = typeof badge === "object" && /^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)$/.test(badge.text);
+const iconName = icon && !icon.startsWith("/")
+ ? icon.includes(":")
+ ? icon
+ : icon === "aws"
+ ? "fa6-brands:aws"
+ : `fa6-solid:${icon}`
+ : undefined;
+const imageIcon = icon?.startsWith("/") ? inlinePublicIcon(icon) : undefined;
---