diff --git a/src/components/DocsSidebar.astro b/src/components/DocsSidebar.astro index 51d94ce..f810501 100644 --- a/src/components/DocsSidebar.astro +++ b/src/components/DocsSidebar.astro @@ -1,7 +1,7 @@ --- import { getCollection } from 'astro:content'; import { getDocsVersions } from '../lib/docs-versions'; -import { productLabel } from '../lib/docs-products'; +import { productLabel, isProductHidden } from '../lib/docs-products'; interface Props { activeId?: string; @@ -14,6 +14,11 @@ type Item = { id: string; title: string; order: number; href: string }; type Section = { key: string; label: string; items: Item[] }; const entries = await getCollection('docs'); +// Hidden products (e.g. private/pre-launch) are dropped from the sidebar so +// they don't appear in any listing. If the reader is already on a hidden +// product's page (via a direct URL), keep its section visible so they can +// navigate within it. +const activeProduct = activeId?.split('/')[0]; const idToHref = (id: string) => { const stripped = id.replace(/\/index$/, ''); @@ -34,6 +39,7 @@ for (const entry of entries) { } const sections: Section[] = Array.from(sectionMap.entries()) + .filter(([key]) => !isProductHidden(key) || key === activeProduct) .map(([key, items]) => ({ key, label: productLabel(key, 'short'), diff --git a/src/lib/docs-products.ts b/src/lib/docs-products.ts index 6c1a5c3..a2c6ecc 100644 --- a/src/lib/docs-products.ts +++ b/src/lib/docs-products.ts @@ -1,10 +1,13 @@ // Display labels for each product slug. Keep in sync with sync-docs.js `sources`. // `short` is used in tight UI (sidebar section header). // `long` is used where the full product name reads better (back link, etc.). -type ProductLabels = { short: string; long: string }; +// `hidden: true` keeps the product's docs reachable by direct URL but excludes +// them from the /docs/ index and the sidebar — used while a product is still +// private/pre-launch. +type ProductLabels = { short: string; long: string; hidden?: boolean }; const LABELS: Record = { - voice: { short: 'Voice', long: 'WaveKat Voice' }, + voice: { short: 'Voice', long: 'WaveKat Voice', hidden: true }, cli: { short: 'CLI', long: 'WaveKat CLI' }, lab: { short: 'Lab', long: 'WaveKat Lab' }, vad: { short: 'VAD', long: 'WaveKat VAD' }, @@ -18,3 +21,7 @@ const LABELS: Record = { export function productLabel(slug: string, form: 'short' | 'long' = 'long'): string { return LABELS[slug]?.[form] ?? slug; } + +export function isProductHidden(slug: string): boolean { + return LABELS[slug]?.hidden ?? false; +} diff --git a/src/pages/docs/index.astro b/src/pages/docs/index.astro index 759ec52..bb5d6dc 100644 --- a/src/pages/docs/index.astro +++ b/src/pages/docs/index.astro @@ -5,6 +5,7 @@ import Header from '../../components/Header.astro'; import Footer from '../../components/Footer.astro'; import DocsSidebar from '../../components/DocsSidebar.astro'; import { getDocsVersions } from '../../lib/docs-versions'; +import { isProductHidden } from '../../lib/docs-products'; type Product = { slug: string; @@ -23,7 +24,7 @@ const liveSlugs = new Set(entries.map((e) => e.id.split('/')[0])); const versions = getDocsVersions(); const products = PRODUCTS - .filter((p) => liveSlugs.has(p.slug)) + .filter((p) => liveSlugs.has(p.slug) && !isProductHidden(p.slug)) .map((p) => ({ ...p, version: versions[p.slug] })); ---