Files

44 lines
2.2 KiB
TypeScript

// Existing Astro book collection filenames, not a second authored guide dataset.
export const documentPaths = [
'/1-concept.md',
'/1.1-interaction-abstraction.md',
'/1.2-existing-abstractions.md',
'/1.3-design-principles.md',
'/1.4-concepts-and-scope.md',
'/2-core-model.md',
'/2.1-object-tree-schema.md',
'/2.2-operation-and-interface.md',
'/3-protocol.md',
'/4-client.md',
'/4.1-ai-tools.md',
'/4.2-text-view.md',
'/5-transports.md',
'/5.1-wip-over-http.md',
];
// Formerly published draft URLs remain regression inputs, never public documents.
export const draftPaths = [
'/draft/dynamic-worldspace-projection.md',
'/draft/filesystem-discovery.md',
'/draft/rust-api-model.md',
'/draft/typescript-api-model.md',
'/draft/unresolved-issues.md',
];
export const catalogPaths = ['/sources', '/packages'];
export const treePaths = ['/', '/book', ...documentPaths, ...catalogPaths, '/playground'];
export const treeNodeCount = treePaths.length;
export const chapterSections: Record<string, string[]> = {
'/1-concept.md': ['/1.1-interaction-abstraction.md', '/1.2-existing-abstractions.md', '/1.3-design-principles.md', '/1.4-concepts-and-scope.md'],
'/2-core-model.md': ['/2.1-object-tree-schema.md', '/2.2-operation-and-interface.md'],
'/4-client.md': ['/4.1-ai-tools.md', '/4.2-text-view.md'],
'/5-transports.md': ['/5.1-wip-over-http.md'],
};
export const treeParents: Record<string, string> = Object.fromEntries(treePaths.filter((path) => path !== '/').map((path) => [path, path === '/book' || catalogPaths.includes(path) || path === '/playground' ? '/' : '/book']));
for (const [chapter, sections] of Object.entries(chapterSections)) {
for (const section of sections) treeParents[section] = chapter;
}
export const rootChildCount = treePaths.filter((path) => treeParents[path] === '/').length;
export const routeURL = (path: string, base: string) => path === '/' ? new URL('./', base).href
: path === '/book' || catalogPaths.includes(path) || path === '/playground' ? new URL(`${path.slice(1)}/`, base).href : bookURL(path, base);
export const bookURL = (path: string, base: string) => new URL(`book/${path.slice(1, -3).split('/').map(encodeURIComponent).join('/')}/`, base).href;