From 569d8756137de407165f3210acf1494b0c601123 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 1 Sep 2026 19:13:54 -0700 Subject: [PATCH] improvement(docs): streamline API reference navigation --- apps/docs/app/openapi.json/route.ts | 11 ++ .../docs-layout/sidebar-components.tsx | 15 +- .../docs/api-reference/getting-started.mdx | 6 +- apps/docs/lib/openapi-download.test.ts | 71 ++++++++ apps/docs/lib/openapi-download.ts | 166 ++++++++++++++++++ 5 files changed, 256 insertions(+), 13 deletions(-) create mode 100644 apps/docs/app/openapi.json/route.ts create mode 100644 apps/docs/lib/openapi-download.test.ts create mode 100644 apps/docs/lib/openapi-download.ts diff --git a/apps/docs/app/openapi.json/route.ts b/apps/docs/app/openapi.json/route.ts new file mode 100644 index 00000000000..b668de90a90 --- /dev/null +++ b/apps/docs/app/openapi.json/route.ts @@ -0,0 +1,11 @@ +import { createOpenApiDownloadDocument } from '@/lib/openapi-download' + +export const revalidate = false + +export function GET() { + return Response.json(createOpenApiDownloadDocument(), { + headers: { + 'Content-Disposition': 'attachment; filename="sim-openapi-v2.json"', + }, + }) +} diff --git a/apps/docs/components/docs-layout/sidebar-components.tsx b/apps/docs/components/docs-layout/sidebar-components.tsx index a899be3a730..2e4112f69f4 100644 --- a/apps/docs/components/docs-layout/sidebar-components.tsx +++ b/apps/docs/components/docs-layout/sidebar-components.tsx @@ -69,23 +69,12 @@ export function SidebarItem({ item }: { item: Item }) { ) } -function isApiReferenceFolder(node: Folder): boolean { - if (node.index?.url.includes('/api-reference/')) return true - for (const child of node.children) { - if (child.type === 'page' && child.url.includes('/api-reference/')) return true - if (child.type === 'folder' && isApiReferenceFolder(child)) return true - } - return false -} - export function SidebarFolder({ item, children }: { item: Folder; children: ReactNode }) { const pathname = usePathname() const { prefetch } = useSidebar() const hasActiveChild = checkHasActiveChild(item, pathname) - const isApiRef = isApiReferenceFolder(item) - const isOnApiRefPage = pathname.startsWith('/api-reference') const hasChildren = item.children.length > 0 - const defaultOpen = hasActiveChild || (isApiRef && isOnApiRefPage) + const defaultOpen = hasActiveChild const [manualOpen, setManualOpen] = useState<{ pathname: string; open: boolean } | null>(null) const open = manualOpen?.pathname === pathname ? manualOpen.open : defaultOpen const toggleOpen = () => setManualOpen({ pathname, open: !open }) @@ -131,6 +120,7 @@ export function SidebarFolder({ item, children }: { item: Folder; children: Reac chipHoverSurfaceClass )} aria-label={open ? 'Collapse' : 'Expand'} + aria-expanded={open} > @@ -139,6 +129,7 @@ export function SidebarFolder({ item, children }: { item: Folder; children: Reac ) : (