---
import { discoveryServices, discoveryMethodTotal } from '../data/discovery-coverage';
interface Props {
/** The current docs route, e.g. `/docs/commands/`. Marks the active page. */
currentPath?: string;
}
const { currentPath = '' } = Astro.props;
const base = import.meta.env.BASE_URL;
const docPages = [
{ href: `${base}docs/`, label: 'Docs overview' },
{ href: `${base}docs/getting-started/`, label: 'Getting started' },
{ href: `${base}docs/commands/`, label: 'Commands' },
{ href: `${base}docs/discovery/`, label: 'Discovery API' },
{ href: `${base}docs/api-reference/`, label: 'API reference' },
{ href: `${base}docs/agents/`, label: 'For agents' },
];
// The overview is active only on its own route; every other page is active on
// itself and anything under it.
const isActive = (href: string) =>
href === `${base}docs/` ? currentPath === href : currentPath.startsWith(href);
---
{/* A <nav> landmark, not an <aside>: every other link group on the site
(primary header, footer, changelog jump) is one, and without it a screen
reader user has no landmark route into the documentation navigation. */}
<nav class="docs-sidenav" aria-label="Documentation" data-pagefind-ignore>
<ul class="menu menu-md w-64 border border-base-300 bg-base-200 p-2">
<li class="menu-title"><span>documentation</span></li>
{
docPages.map((page) => (
<li>
<a class:list={[{ 'menu-active': isActive(page.href) }]} href={page.href} aria-current={isActive(page.href) ? 'page' : undefined}>
{page.label}
</a>
</li>
))
}
<li class="menu-title mt-3"><span>services · {discoveryMethodTotal} methods</span></li>
{
/* Each service points at its API reference page — the per-service
documentation baked from the same index, which the commands page's
own in-page anchors complement. */
discoveryServices.map((service) => (
<li>
<a
class:list={[{ 'menu-active': isActive(`${base}docs/api-reference/${service.name}/`) }]}
href={`${base}docs/api-reference/${service.name}/`}
aria-current={isActive(`${base}docs/api-reference/${service.name}/`) ? 'page' : undefined}
>
<span>{service.label}</span>
<span class="badge badge-ghost badge-sm ml-auto">{service.methods}</span>
</a>
</li>
))
}
</ul>
</nav>