Refocus manual on public language usage
This commit is contained in:
@@ -7,19 +7,26 @@ const modules = import.meta.glob('../../../../doc/manual/souce/**/*.md', {
|
||||
eager: true,
|
||||
});
|
||||
|
||||
const documentEntries = Object.entries(modules).map(([path, content]) => {
|
||||
const sourcePath = path
|
||||
.replace(/^\.\.\/\.\.\/\.\.\/\.\.\/doc\/manual\/souce\//, '')
|
||||
.replace(/\.md$/, '');
|
||||
const parts = sourcePath.split('/');
|
||||
parts.pop();
|
||||
const slug = sourcePath.replace(/\/index$/, '') || 'index';
|
||||
return { slug, content, base: parts };
|
||||
});
|
||||
|
||||
export const docs = Object.fromEntries(
|
||||
Object.entries(modules).map(([path, content]) => {
|
||||
const slug = path
|
||||
.replace(/^\.\.\/\.\.\/\.\.\/\.\.\/doc\/manual\/souce\//, '')
|
||||
.replace(/\.md$/, '')
|
||||
.replace(/\/index$/, '');
|
||||
return [slug || 'index', content];
|
||||
}),
|
||||
documentEntries.map(({ slug, content }) => [slug, content]),
|
||||
);
|
||||
|
||||
const docBases = Object.fromEntries(
|
||||
documentEntries.map(({ slug, base }) => [slug, base]),
|
||||
);
|
||||
|
||||
export const nav = [
|
||||
{ title: 'Introduction', slug: 'introduction' },
|
||||
{ title: 'Components', slug: 'components' },
|
||||
{
|
||||
title: 'Language Specification',
|
||||
slug: 'language',
|
||||
@@ -51,10 +58,10 @@ export const nav = [
|
||||
{ title: 'Match', slug: 'language/expression/match' },
|
||||
{ title: 'Import', slug: 'language/expression/import' },
|
||||
{ title: 'Composition', slug: 'language/expression/composition' },
|
||||
{ title: 'Range Refinement', slug: 'language/expression/ascription' },
|
||||
{ title: 'Default', slug: 'language/expression/default' },
|
||||
{ title: 'Arithmetic', slug: 'language/expression/arithmetic' },
|
||||
{ title: 'Logical and Comparison', slug: 'language/expression/logical-and-comparison' },
|
||||
{ title: 'String Interpolation', slug: 'language/expression/string-interpolation' },
|
||||
],
|
||||
},
|
||||
{ title: 'Constraints and Defaults', slug: 'language/constraints-and-defaults' },
|
||||
@@ -67,21 +74,8 @@ export const nav = [
|
||||
{ title: 'Examples', slug: 'language/examples' },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Implementation Design',
|
||||
slug: 'design',
|
||||
children: [
|
||||
{ title: 'Execution Pipeline', slug: 'design/execution-pipeline' },
|
||||
{ title: 'Runtime Model', slug: 'design/runtime-model' },
|
||||
{ title: 'Thunk and Lazy Evaluation', slug: 'design/thunk-and-lazy-evaluation' },
|
||||
{ title: 'Composition and Materialization', slug: 'design/composition-and-materialization' },
|
||||
{ title: 'Diagnostics and Fallback', slug: 'design/diagnostics-and-fallback' },
|
||||
{ title: 'Embedding API', slug: 'design/embedding-api' },
|
||||
{ title: 'Features', slug: 'design/features' },
|
||||
],
|
||||
},
|
||||
{ title: 'Development', slug: 'development' },
|
||||
{ title: 'Open Issues', slug: 'open-issues' },
|
||||
{ title: 'Embedding', slug: 'embedding' },
|
||||
{ title: 'Packages and Integrations', slug: 'components' },
|
||||
];
|
||||
|
||||
const renderer = new marked.Renderer();
|
||||
@@ -105,12 +99,13 @@ export function renderMarkdown(slug) {
|
||||
const html = marked.parse(source ?? '# Not found\n');
|
||||
return html.replace(/href="([^"#][^"]*)\.md(#[^"]*)?"/g, (_all, href, hash = '') => {
|
||||
const target = normalizeDocLink(slug, href);
|
||||
return `href="/docs/${target}/${hash}"`;
|
||||
const pathname = target === 'index' ? '/docs/' : `/docs/${target}/`;
|
||||
return `href="${pathname}${hash}"`;
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeDocLink(currentSlug, href) {
|
||||
const base = currentSlug.includes('/') ? currentSlug.split('/').slice(0, -1) : [];
|
||||
const base = docBases[currentSlug] ?? [];
|
||||
const parts = [...base, ...href.split('/')];
|
||||
const out = [];
|
||||
for (const part of parts) {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
---
|
||||
return Astro.redirect('/docs/introduction/');
|
||||
import ManualLayout from '../../layouts/ManualLayout.astro';
|
||||
import { renderMarkdown } from '../../lib/docs.js';
|
||||
|
||||
const html = renderMarkdown('index');
|
||||
---
|
||||
<ManualLayout title="Decodal Manual" active="index">
|
||||
<article class="markdown" set:html={html} />
|
||||
</ManualLayout>
|
||||
|
||||
Reference in New Issue
Block a user