Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/DocsSidebar.astro
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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$/, '');
Expand All @@ -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'),
Expand Down
11 changes: 9 additions & 2 deletions src/lib/docs-products.ts
Original file line number Diff line number Diff line change
@@ -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<string, ProductLabels> = {
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' },
Expand All @@ -18,3 +21,7 @@ const LABELS: Record<string, ProductLabels> = {
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;
}
3 changes: 2 additions & 1 deletion src/pages/docs/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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] }));
---

Expand Down
Loading