09433415b6
Adds a hand-authored .vue doc-sections system (intro + guide pages per package, #docs/sections map, sidebar Guide group, client-side TOC), registers @robonen/crdt, renders demos client-only, base64-encodes the server-metadata virtual, plus the MCP docs endpoint and responsive/overflow fixes across pages and tables.
280 lines
9.3 KiB
TypeScript
280 lines
9.3 KiB
TypeScript
/**
|
|
* Pure, framework-agnostic query layer over the extractor's {@link DocsMetadata}.
|
|
*
|
|
* The MCP server (and its tests) build a flat index of every documented leaf —
|
|
* api items, components and guide sections alike — and run search / lookup over
|
|
* it. Nothing here touches the MCP SDK or the filesystem, so it stays trivially
|
|
* unit-testable.
|
|
*/
|
|
|
|
import type {
|
|
CategoryMeta,
|
|
ComponentMeta,
|
|
DocsMetadata,
|
|
GuideSection,
|
|
ItemMeta,
|
|
PackageGroup,
|
|
PackageMeta,
|
|
} from '../extractor/types';
|
|
|
|
/** A normalised, discriminated reference to any documented leaf. */
|
|
export type DocEntry
|
|
= | { kind: 'api'; pkg: PackageMeta; category: CategoryMeta; item: ItemMeta }
|
|
| { kind: 'components'; pkg: PackageMeta; component: ComponentMeta }
|
|
| { kind: 'guide'; pkg: PackageMeta; section: GuideSection };
|
|
|
|
/** A flat, search-friendly record for a single documented leaf. */
|
|
export interface Leaf {
|
|
packageSlug: string;
|
|
packageName: string;
|
|
group: PackageGroup;
|
|
/** Display badge: the item kind, or `component` / `guide`. */
|
|
badge: string;
|
|
/** URL-friendly slug, unique within its package. */
|
|
slug: string;
|
|
/** Display name. */
|
|
name: string;
|
|
description: string;
|
|
/** Back-reference to the structured entry for rich rendering. */
|
|
entry: DocEntry;
|
|
/** Lowercased haystack used for substring search. */
|
|
haystack: string;
|
|
}
|
|
|
|
export interface SearchHit {
|
|
packageSlug: string;
|
|
packageName: string;
|
|
badge: string;
|
|
slug: string;
|
|
name: string;
|
|
description: string;
|
|
score: number;
|
|
}
|
|
|
|
export const GROUP_LABELS: Record<PackageGroup, string> = {
|
|
core: 'Core',
|
|
vue: 'Vue',
|
|
configs: 'Configs',
|
|
infra: 'Infra',
|
|
};
|
|
|
|
export const GROUP_ORDER: PackageGroup[] = ['core', 'vue', 'configs', 'infra'];
|
|
|
|
/** Join a list of strings into a lowercased search haystack, skipping empties. */
|
|
function haystackOf(parts: Array<string | undefined | null>): string {
|
|
return parts.filter(Boolean).join(' |