@entifix/docs-engine 0.0.0-bootstrap.0 → 0.23.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +95 -1
- package/dist/directives.d.ts +25 -0
- package/dist/directives.d.ts.map +1 -0
- package/dist/directives.js +107 -0
- package/dist/directives.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/links.d.ts +19 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +17 -0
- package/dist/links.js.map +1 -0
- package/dist/markdown.d.ts +24 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +47 -0
- package/dist/markdown.js.map +1 -0
- package/dist/references.d.ts +20 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +16 -0
- package/dist/references.js.map +1 -0
- package/dist/site.d.ts +46 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +90 -0
- package/dist/site.js.map +1 -0
- package/dist/sources.d.ts +65 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/sources.js +115 -0
- package/dist/sources.js.map +1 -0
- package/dist/spec-support.d.ts +6 -0
- package/dist/spec-support.d.ts.map +1 -0
- package/dist/spec-support.js +17 -0
- package/dist/spec-support.js.map +1 -0
- package/dist/ui/head.d.ts +16 -0
- package/dist/ui/head.d.ts.map +1 -0
- package/dist/ui/head.js +29 -0
- package/dist/ui/head.js.map +1 -0
- package/dist/ui/index.d.ts +13 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +9 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/layout.d.ts +15 -0
- package/dist/ui/layout.d.ts.map +1 -0
- package/dist/ui/layout.js +30 -0
- package/dist/ui/layout.js.map +1 -0
- package/dist/ui/page.d.ts +21 -0
- package/dist/ui/page.d.ts.map +1 -0
- package/dist/ui/page.js +70 -0
- package/dist/ui/page.js.map +1 -0
- package/dist/ui/pagefind.d.ts +37 -0
- package/dist/ui/pagefind.d.ts.map +1 -0
- package/dist/ui/pagefind.js +48 -0
- package/dist/ui/pagefind.js.map +1 -0
- package/dist/ui/root.d.ts +22 -0
- package/dist/ui/root.d.ts.map +1 -0
- package/dist/ui/root.js +85 -0
- package/dist/ui/root.js.map +1 -0
- package/dist/ui/scheme.d.ts +12 -0
- package/dist/ui/scheme.d.ts.map +1 -0
- package/dist/ui/scheme.js +17 -0
- package/dist/ui/scheme.js.map +1 -0
- package/dist/ui/search-dialog.d.ts +15 -0
- package/dist/ui/search-dialog.d.ts.map +1 -0
- package/dist/ui/search-dialog.js +60 -0
- package/dist/ui/search-dialog.js.map +1 -0
- package/dist/ui/skip-link.d.ts +7 -0
- package/dist/ui/skip-link.d.ts.map +1 -0
- package/dist/ui/skip-link.js +17 -0
- package/dist/ui/skip-link.js.map +1 -0
- package/dist/ui/translations.d.ts +12 -0
- package/dist/ui/translations.d.ts.map +1 -0
- package/dist/ui/translations.js +48 -0
- package/dist/ui/translations.js.map +1 -0
- package/package.json +87 -3
- package/src/ui/docs.css +154 -0
package/dist/site.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { loader } from 'fumadocs-core/source';
|
|
3
|
+
import { DocsContentError } from './errors.js';
|
|
4
|
+
import { checkMarkdown, renderMarkdown } from './markdown.js';
|
|
5
|
+
const keyOf = (slugs)=>slugs.join('/');
|
|
6
|
+
/** A page's file, as fumadocs reads the tree: `records/0031.md`, `guides/index.md`. */ const pathOf = (slugs)=>slugs.length === 1 ? `${slugs[0]}/index.md` : `${keyOf(slugs)}.md`;
|
|
7
|
+
/** The direct children of a folder, in the source's order. */ const childrenOf = (source)=>[
|
|
8
|
+
...new Set(source.pages.map((page)=>page.slugs.length === 1 ? 'index' : page.slugs[1]))
|
|
9
|
+
];
|
|
10
|
+
const virtualFiles = (sources)=>[
|
|
11
|
+
{
|
|
12
|
+
type: 'meta',
|
|
13
|
+
path: 'meta.json',
|
|
14
|
+
data: {
|
|
15
|
+
pages: sources.map((source)=>source.folder)
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
...sources.flatMap((source)=>[
|
|
19
|
+
{
|
|
20
|
+
type: 'meta',
|
|
21
|
+
path: `${source.folder}/meta.json`,
|
|
22
|
+
data: {
|
|
23
|
+
title: source.title,
|
|
24
|
+
pages: [
|
|
25
|
+
...childrenOf(source),
|
|
26
|
+
'...'
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
...source.pages.map((page)=>({
|
|
31
|
+
type: 'page',
|
|
32
|
+
path: pathOf(page.slugs),
|
|
33
|
+
slugs: [
|
|
34
|
+
...page.slugs
|
|
35
|
+
],
|
|
36
|
+
// fumadocs types a page's data as its own frontmatter shape; the
|
|
37
|
+
// engine's carries the input beside it, read back by `page()`.
|
|
38
|
+
data: _extends({
|
|
39
|
+
title: page.title
|
|
40
|
+
}, page.description === undefined ? {} : {
|
|
41
|
+
description: page.description
|
|
42
|
+
}, {
|
|
43
|
+
input: page
|
|
44
|
+
})
|
|
45
|
+
}))
|
|
46
|
+
])
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* One site from its sources: a `fumadocs-core` page tree, the pages a route
|
|
50
|
+
* renders, and the parameters a static export enumerates.
|
|
51
|
+
*
|
|
52
|
+
* Every page is checked when the site is created — a duplicate address, an
|
|
53
|
+
* unknown directive, an id the registry does not hold — so `next build` stops
|
|
54
|
+
* on the first mistake with its file and line, whichever pages a reader would
|
|
55
|
+
* visit.
|
|
56
|
+
*/ export const createDocsSite = ({ baseUrl, sources, references = {} })=>{
|
|
57
|
+
const seen = new Map();
|
|
58
|
+
for (const page of sources.flatMap((source)=>source.pages)){
|
|
59
|
+
const key = keyOf(page.slugs);
|
|
60
|
+
const earlier = seen.get(key);
|
|
61
|
+
if (earlier !== undefined) {
|
|
62
|
+
throw new DocsContentError(page.file, `is served at /${key}, which ${earlier} already is`);
|
|
63
|
+
}
|
|
64
|
+
seen.set(key, page.file);
|
|
65
|
+
checkMarkdown(page.markdown, page.file, references);
|
|
66
|
+
}
|
|
67
|
+
const source = loader({
|
|
68
|
+
baseUrl,
|
|
69
|
+
source: {
|
|
70
|
+
files: virtualFiles(sources)
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
source,
|
|
75
|
+
/** The page tree the layout's sidebar renders. */ pageTree: source.pageTree,
|
|
76
|
+
/** A page by its slugs, or `undefined` for an address nothing serves. */ page: (slugs)=>{
|
|
77
|
+
const found = source.getPage([
|
|
78
|
+
...slugs != null ? slugs : []
|
|
79
|
+
]);
|
|
80
|
+
return found === undefined ? undefined : {
|
|
81
|
+
url: found.url,
|
|
82
|
+
data: found.data
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
/** A page's body and table of contents. */ render: (data)=>renderMarkdown(data.input.markdown, data.input.file, references),
|
|
86
|
+
/** Every address, for `generateStaticParams`. */ params: ()=>source.generateParams()
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=site.js.map
|
package/dist/site.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/site.ts"],"sourcesContent":["import { loader, type PageData, type VirtualFile } from 'fumadocs-core/source';\n\nimport { DocsContentError } from './errors.js';\nimport { checkMarkdown, renderMarkdown } from './markdown.js';\nimport type { ReferenceRegistry } from './references.js';\nimport type { DocsPageInput, DocsSource } from './sources.js';\n\nexport interface DocsSiteOptions {\n /** Where the pages are served, below the app's `basePath`: `/docs`. */\n readonly baseUrl: string;\n /** The sections, in the order the sidebar shows them. */\n readonly sources: readonly DocsSource[];\n /** What each citation directive resolves against. */\n readonly references?: ReferenceRegistry;\n}\n\n/** What a page carries into the loader, and what a route reads back. */\nexport interface DocsPageData {\n readonly title: string;\n readonly description?: string;\n readonly input: DocsPageInput;\n}\n\nconst keyOf = (slugs: readonly string[]) => slugs.join('/');\n\n/** A page's file, as fumadocs reads the tree: `records/0031.md`, `guides/index.md`. */\nconst pathOf = (slugs: readonly string[]) =>\n slugs.length === 1 ? `${slugs[0]}/index.md` : `${keyOf(slugs)}.md`;\n\n/** The direct children of a folder, in the source's order. */\nconst childrenOf = (source: DocsSource): string[] => [\n ...new Set(\n source.pages.map(page =>\n page.slugs.length === 1 ? 'index' : (page.slugs[1] as string),\n ),\n ),\n];\n\nconst virtualFiles = (sources: readonly DocsSource[]): VirtualFile[] => [\n {\n type: 'meta',\n path: 'meta.json',\n data: { pages: sources.map(source => source.folder) },\n },\n ...sources.flatMap((source): VirtualFile[] => [\n {\n type: 'meta',\n path: `${source.folder}/meta.json`,\n data: { title: source.title, pages: [...childrenOf(source), '...'] },\n },\n ...source.pages.map((page): VirtualFile => ({\n type: 'page',\n path: pathOf(page.slugs),\n slugs: [...page.slugs],\n // fumadocs types a page's data as its own frontmatter shape; the\n // engine's carries the input beside it, read back by `page()`.\n data: {\n title: page.title,\n ...(page.description === undefined\n ? {}\n : { description: page.description }),\n input: page,\n } satisfies DocsPageData as PageData,\n })),\n ]),\n];\n\n/**\n * One site from its sources: a `fumadocs-core` page tree, the pages a route\n * renders, and the parameters a static export enumerates.\n *\n * Every page is checked when the site is created — a duplicate address, an\n * unknown directive, an id the registry does not hold — so `next build` stops\n * on the first mistake with its file and line, whichever pages a reader would\n * visit.\n */\nexport const createDocsSite = ({\n baseUrl,\n sources,\n references = {},\n}: DocsSiteOptions) => {\n const seen = new Map<string, string>();\n for (const page of sources.flatMap(source => source.pages)) {\n const key = keyOf(page.slugs);\n const earlier = seen.get(key);\n if (earlier !== undefined) {\n throw new DocsContentError(\n page.file,\n `is served at /${key}, which ${earlier} already is`,\n );\n }\n seen.set(key, page.file);\n checkMarkdown(page.markdown, page.file, references);\n }\n\n const source = loader({\n baseUrl,\n source: { files: virtualFiles(sources) },\n });\n\n return {\n source,\n /** The page tree the layout's sidebar renders. */\n pageTree: source.pageTree,\n /** A page by its slugs, or `undefined` for an address nothing serves. */\n page: (slugs: readonly string[] | undefined) => {\n const found = source.getPage([...(slugs ?? [])]);\n return found === undefined\n ? undefined\n : { url: found.url, data: found.data as unknown as DocsPageData };\n },\n /** A page's body and table of contents. */\n render: (data: DocsPageData) =>\n renderMarkdown(data.input.markdown, data.input.file, references),\n /** Every address, for `generateStaticParams`. */\n params: () => source.generateParams(),\n };\n};\n\nexport type DocsSite = ReturnType<typeof createDocsSite>;\n"],"names":["loader","DocsContentError","checkMarkdown","renderMarkdown","keyOf","slugs","join","pathOf","length","childrenOf","source","Set","pages","map","page","virtualFiles","sources","type","path","data","folder","flatMap","title","description","undefined","input","createDocsSite","baseUrl","references","seen","Map","key","earlier","get","file","set","markdown","files","pageTree","found","getPage","url","render","params","generateParams"],"mappings":"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"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type RecordEntry } from '@entifix/docs/reader';
|
|
2
|
+
import { type LinkTargets } from './links.js';
|
|
3
|
+
/** One page a source contributes, before the engine checks and renders it. */
|
|
4
|
+
export interface DocsPageInput {
|
|
5
|
+
/** Its address under the site's base URL: `['records', '0031']`. */
|
|
6
|
+
readonly slugs: readonly string[];
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
/** The body, in Markdown with the engine's directives. */
|
|
10
|
+
readonly markdown: string;
|
|
11
|
+
/** Where it came from, for an error. */
|
|
12
|
+
readonly file: string;
|
|
13
|
+
/** The record it was read from, for a records page. */
|
|
14
|
+
readonly record?: RecordEntry;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A section of the site: the pages one source contributes, under one folder,
|
|
18
|
+
* in the order the sidebar shows them.
|
|
19
|
+
*/
|
|
20
|
+
export interface DocsSource {
|
|
21
|
+
/** The folder its pages sit in, the first slug of each: `records`. */
|
|
22
|
+
readonly folder: string;
|
|
23
|
+
/** The folder's caption in the sidebar. */
|
|
24
|
+
readonly title: string;
|
|
25
|
+
readonly pages: readonly DocsPageInput[];
|
|
26
|
+
}
|
|
27
|
+
export interface RecordsSourceOptions {
|
|
28
|
+
/** The collection: a directory of `NNNN-*.md` records. */
|
|
29
|
+
readonly directory: string;
|
|
30
|
+
/** The areas a record may be filed under. */
|
|
31
|
+
readonly areas: readonly string[];
|
|
32
|
+
readonly folder?: string;
|
|
33
|
+
readonly title: string;
|
|
34
|
+
/** Where a record's relative links go. */
|
|
35
|
+
readonly links: LinkTargets;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Every record of a collection, one page each, read with
|
|
39
|
+
* `@entifix/docs/reader` — the one parser (entifix ADR 0031 §1). A collection
|
|
40
|
+
* the reader finds problems in is not a site: the problems stop the build.
|
|
41
|
+
*/
|
|
42
|
+
export declare const recordsSource: ({ directory, areas, folder, title, links, }: RecordsSourceOptions) => DocsSource;
|
|
43
|
+
export interface GuidesSourceOptions {
|
|
44
|
+
/** A directory of Markdown guides; subdirectories become nested slugs. */
|
|
45
|
+
readonly directory: string;
|
|
46
|
+
readonly folder?: string;
|
|
47
|
+
readonly title: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Markdown guides, one page per file, titled by their frontmatter and ordered
|
|
51
|
+
* by its `order` (then by file name). A guide cites what it describes with the
|
|
52
|
+
* engine's directives, checked when the site is created.
|
|
53
|
+
*/
|
|
54
|
+
export declare const guidesSource: ({ directory, folder, title, }: GuidesSourceOptions) => DocsSource;
|
|
55
|
+
/** A page a host derives, addressed relative to its folder. */
|
|
56
|
+
export type ReferencePage = Omit<DocsPageInput, 'slugs' | 'record'> & {
|
|
57
|
+
readonly path: readonly string[];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Pages a host derives from its own metadata — entities, use cases, endpoints.
|
|
61
|
+
* The engine knows no host's entities; the host writes the function and hands
|
|
62
|
+
* the engine its pages (entifix ADR 0031 §3).
|
|
63
|
+
*/
|
|
64
|
+
export declare const referenceSource: (folder: string, title: string, derive: () => readonly ReferencePage[]) => DocsSource;
|
|
65
|
+
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../src/sources.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIrE,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,YAAY,CAAC;AAE5D,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAID;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,6CAM3B,oBAAoB,KAAG,UAoBzB,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AA8BD;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,+BAI1B,mBAAmB,KAAG,UAuBvB,CAAC;AAEH,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,QAAQ,CAAC,GAAG;IACpE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,MAAM,EACd,OAAO,MAAM,EACb,QAAQ,MAAM,SAAS,aAAa,EAAE,KACrC,UAOD,CAAC"}
|
package/dist/sources.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
3
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
4
|
+
import { join, relative, sep } from 'node:path';
|
|
5
|
+
import { readRecords } from '@entifix/docs/reader';
|
|
6
|
+
import { frontmatter } from 'fumadocs-core/content/md/frontmatter';
|
|
7
|
+
import { DocsContentError } from './errors.js';
|
|
8
|
+
import { rewriteLinks } from './links.js';
|
|
9
|
+
const RECORD_TITLE = /^#\s+\d+\.\s+/;
|
|
10
|
+
/**
|
|
11
|
+
* Every record of a collection, one page each, read with
|
|
12
|
+
* `@entifix/docs/reader` — the one parser (entifix ADR 0031 §1). A collection
|
|
13
|
+
* the reader finds problems in is not a site: the problems stop the build.
|
|
14
|
+
*/ export const recordsSource = ({ directory, areas, folder = 'records', title, links })=>{
|
|
15
|
+
const { records, problems } = readRecords(directory, {
|
|
16
|
+
areas
|
|
17
|
+
});
|
|
18
|
+
if (problems.length > 0) {
|
|
19
|
+
throw new DocsContentError(directory, problems.join('; '));
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
folder,
|
|
23
|
+
title,
|
|
24
|
+
pages: records.map((record)=>{
|
|
25
|
+
const file = join(directory, record.file);
|
|
26
|
+
const [, ...body] = readFileSync(file, 'utf8').split('\n');
|
|
27
|
+
return {
|
|
28
|
+
slugs: [
|
|
29
|
+
folder,
|
|
30
|
+
record.id
|
|
31
|
+
],
|
|
32
|
+
title: `${record.number}. ${record.title.replace(RECORD_TITLE, '')}`,
|
|
33
|
+
markdown: rewriteLinks(body.join('\n'), links),
|
|
34
|
+
file,
|
|
35
|
+
record
|
|
36
|
+
};
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const markdownFiles = (directory)=>readdirSync(directory).sort().flatMap((name)=>{
|
|
41
|
+
const path = join(directory, name);
|
|
42
|
+
if (statSync(path).isDirectory()) return markdownFiles(path);
|
|
43
|
+
return name.endsWith('.md') ? [
|
|
44
|
+
path
|
|
45
|
+
] : [];
|
|
46
|
+
});
|
|
47
|
+
const frontmatterOf = (file, input)=>{
|
|
48
|
+
const { data, content } = frontmatter(input);
|
|
49
|
+
// fumadocs answers `{}` for a file with no frontmatter at all.
|
|
50
|
+
const fields = data;
|
|
51
|
+
const { title, description, order } = fields;
|
|
52
|
+
if (typeof title !== 'string' || title.trim() === '') {
|
|
53
|
+
throw new DocsContentError(file, 'needs a `title` in its frontmatter');
|
|
54
|
+
}
|
|
55
|
+
return _extends({
|
|
56
|
+
title
|
|
57
|
+
}, typeof description === 'string' ? {
|
|
58
|
+
description
|
|
59
|
+
} : {}, {
|
|
60
|
+
order: typeof order === 'number' ? order : Number.MAX_SAFE_INTEGER,
|
|
61
|
+
content
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Markdown guides, one page per file, titled by their frontmatter and ordered
|
|
66
|
+
* by its `order` (then by file name). A guide cites what it describes with the
|
|
67
|
+
* engine's directives, checked when the site is created.
|
|
68
|
+
*/ export const guidesSource = ({ directory, folder = 'guides', title })=>({
|
|
69
|
+
folder,
|
|
70
|
+
title,
|
|
71
|
+
pages: markdownFiles(directory).map((file)=>{
|
|
72
|
+
const read = frontmatterOf(file, readFileSync(file, 'utf8'));
|
|
73
|
+
const path = relative(directory, file).split(sep);
|
|
74
|
+
const last = path.pop().replace(/\.md$/, '');
|
|
75
|
+
return {
|
|
76
|
+
order: read.order,
|
|
77
|
+
page: _extends({
|
|
78
|
+
slugs: [
|
|
79
|
+
folder,
|
|
80
|
+
...path,
|
|
81
|
+
...last === 'index' ? [] : [
|
|
82
|
+
last
|
|
83
|
+
]
|
|
84
|
+
],
|
|
85
|
+
title: read.title
|
|
86
|
+
}, read.description === undefined ? {} : {
|
|
87
|
+
description: read.description
|
|
88
|
+
}, {
|
|
89
|
+
markdown: read.content,
|
|
90
|
+
file
|
|
91
|
+
})
|
|
92
|
+
};
|
|
93
|
+
}).sort((a, b)=>a.order - b.order).map(({ page })=>page)
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Pages a host derives from its own metadata — entities, use cases, endpoints.
|
|
97
|
+
* The engine knows no host's entities; the host writes the function and hands
|
|
98
|
+
* the engine its pages (entifix ADR 0031 §3).
|
|
99
|
+
*/ export const referenceSource = (folder, title, derive)=>({
|
|
100
|
+
folder,
|
|
101
|
+
title,
|
|
102
|
+
pages: derive().map((_0)=>{
|
|
103
|
+
let { path } = _0, page = _object_without_properties_loose(_0, [
|
|
104
|
+
"path"
|
|
105
|
+
]);
|
|
106
|
+
return _extends({}, page, {
|
|
107
|
+
slugs: [
|
|
108
|
+
folder,
|
|
109
|
+
...path
|
|
110
|
+
]
|
|
111
|
+
});
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sources.ts"],"sourcesContent":["import { readdirSync, readFileSync, statSync } from 'node:fs';\nimport { join, relative, sep } from 'node:path';\n\nimport { readRecords, type RecordEntry } from '@entifix/docs/reader';\nimport { frontmatter } from 'fumadocs-core/content/md/frontmatter';\n\nimport { DocsContentError } from './errors.js';\nimport { type LinkTargets, rewriteLinks } from './links.js';\n\n/** One page a source contributes, before the engine checks and renders it. */\nexport interface DocsPageInput {\n /** Its address under the site's base URL: `['records', '0031']`. */\n readonly slugs: readonly string[];\n readonly title: string;\n readonly description?: string;\n /** The body, in Markdown with the engine's directives. */\n readonly markdown: string;\n /** Where it came from, for an error. */\n readonly file: string;\n /** The record it was read from, for a records page. */\n readonly record?: RecordEntry;\n}\n\n/**\n * A section of the site: the pages one source contributes, under one folder,\n * in the order the sidebar shows them.\n */\nexport interface DocsSource {\n /** The folder its pages sit in, the first slug of each: `records`. */\n readonly folder: string;\n /** The folder's caption in the sidebar. */\n readonly title: string;\n readonly pages: readonly DocsPageInput[];\n}\n\nexport interface RecordsSourceOptions {\n /** The collection: a directory of `NNNN-*.md` records. */\n readonly directory: string;\n /** The areas a record may be filed under. */\n readonly areas: readonly string[];\n readonly folder?: string;\n readonly title: string;\n /** Where a record's relative links go. */\n readonly links: LinkTargets;\n}\n\nconst RECORD_TITLE = /^#\\s+\\d+\\.\\s+/;\n\n/**\n * Every record of a collection, one page each, read with\n * `@entifix/docs/reader` — the one parser (entifix ADR 0031 §1). A collection\n * the reader finds problems in is not a site: the problems stop the build.\n */\nexport const recordsSource = ({\n directory,\n areas,\n folder = 'records',\n title,\n links,\n}: RecordsSourceOptions): DocsSource => {\n const { records, problems } = readRecords(directory, { areas });\n if (problems.length > 0) {\n throw new DocsContentError(directory, problems.join('; '));\n }\n return {\n folder,\n title,\n pages: records.map(record => {\n const file = join(directory, record.file);\n const [, ...body] = readFileSync(file, 'utf8').split('\\n');\n return {\n slugs: [folder, record.id],\n title: `${record.number}. ${record.title.replace(RECORD_TITLE, '')}`,\n markdown: rewriteLinks(body.join('\\n'), links),\n file,\n record,\n };\n }),\n };\n};\n\nexport interface GuidesSourceOptions {\n /** A directory of Markdown guides; subdirectories become nested slugs. */\n readonly directory: string;\n readonly folder?: string;\n readonly title: string;\n}\n\nconst markdownFiles = (directory: string): string[] =>\n readdirSync(directory)\n .sort()\n .flatMap(name => {\n const path = join(directory, name);\n if (statSync(path).isDirectory()) return markdownFiles(path);\n return name.endsWith('.md') ? [path] : [];\n });\n\nconst frontmatterOf = (\n file: string,\n input: string,\n): { title: string; description?: string; order: number; content: string } => {\n const { data, content } = frontmatter(input);\n // fumadocs answers `{}` for a file with no frontmatter at all.\n const fields = data as Record<string, unknown>;\n const { title, description, order } = fields;\n if (typeof title !== 'string' || title.trim() === '') {\n throw new DocsContentError(file, 'needs a `title` in its frontmatter');\n }\n return {\n title,\n ...(typeof description === 'string' ? { description } : {}),\n order: typeof order === 'number' ? order : Number.MAX_SAFE_INTEGER,\n content,\n };\n};\n\n/**\n * Markdown guides, one page per file, titled by their frontmatter and ordered\n * by its `order` (then by file name). A guide cites what it describes with the\n * engine's directives, checked when the site is created.\n */\nexport const guidesSource = ({\n directory,\n folder = 'guides',\n title,\n}: GuidesSourceOptions): DocsSource => ({\n folder,\n title,\n pages: markdownFiles(directory)\n .map(file => {\n const read = frontmatterOf(file, readFileSync(file, 'utf8'));\n const path = relative(directory, file).split(sep);\n const last = (path.pop() as string).replace(/\\.md$/, '');\n return {\n order: read.order,\n page: {\n slugs: [folder, ...path, ...(last === 'index' ? [] : [last])],\n title: read.title,\n ...(read.description === undefined\n ? {}\n : { description: read.description }),\n markdown: read.content,\n file,\n },\n };\n })\n .sort((a, b) => a.order - b.order)\n .map(({ page }) => page),\n});\n\n/** A page a host derives, addressed relative to its folder. */\nexport type ReferencePage = Omit<DocsPageInput, 'slugs' | 'record'> & {\n readonly path: readonly string[];\n};\n\n/**\n * Pages a host derives from its own metadata — entities, use cases, endpoints.\n * The engine knows no host's entities; the host writes the function and hands\n * the engine its pages (entifix ADR 0031 §3).\n */\nexport const referenceSource = (\n folder: string,\n title: string,\n derive: () => readonly ReferencePage[],\n): DocsSource => ({\n folder,\n title,\n pages: derive().map(({ path, ...page }) => ({\n ...page,\n slugs: [folder, ...path],\n })),\n});\n"],"names":["readdirSync","readFileSync","statSync","join","relative","sep","readRecords","frontmatter","DocsContentError","rewriteLinks","RECORD_TITLE","recordsSource","directory","areas","folder","title","links","records","problems","length","pages","map","record","file","body","split","slugs","id","number","replace","markdown","markdownFiles","sort","flatMap","name","path","isDirectory","endsWith","frontmatterOf","input","data","content","fields","description","order","trim","Number","MAX_SAFE_INTEGER","guidesSource","read","last","pop","page","undefined","a","b","referenceSource","derive"],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** A directory holding `files`, nested by their paths. */
|
|
2
|
+
export declare const directoryOf: (files: Record<string, string>) => string;
|
|
3
|
+
/** A record in entifix's format. */
|
|
4
|
+
export declare const record: (number: number, body?: string, area?: string) => string;
|
|
5
|
+
export declare const guide: (title: string, body: string, extra?: string) => string;
|
|
6
|
+
//# sourceMappingURL=spec-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-support.d.ts","sourceRoot":"","sources":["../src/spec-support.ts"],"names":[],"mappings":"AAIA,0DAA0D;AAC1D,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MAO3D,CAAC;AAEF,oCAAoC;AACpC,eAAO,MAAM,MAAM,GACjB,QAAQ,MAAM,EACd,aAAoC,EACpC,aAAiB,KAChB,MACgI,CAAC;AAEpI,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,MAAM,MAAM,EAAE,cAAU,KAAG,MAChB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
/** A directory holding `files`, nested by their paths. */ export const directoryOf = (files)=>{
|
|
5
|
+
const directory = mkdtempSync(join(tmpdir(), 'docs-engine-'));
|
|
6
|
+
for (const [name, text] of Object.entries(files)){
|
|
7
|
+
mkdirSync(dirname(join(directory, name)), {
|
|
8
|
+
recursive: true
|
|
9
|
+
});
|
|
10
|
+
writeFileSync(join(directory, name), text);
|
|
11
|
+
}
|
|
12
|
+
return directory;
|
|
13
|
+
};
|
|
14
|
+
/** A record in entifix's format. */ export const record = (number, body = '## Decision\n\nWe decide.\n', area = 'platform')=>`# ${number}. Title ${number}\n\n- Status: Accepted\n- Date: 2026-11-17\n- Area: ${area}\n- Read when: a thing breaks\n\n${body}`;
|
|
15
|
+
export const guide = (title, body, extra = '')=>`---\ntitle: ${title}\n${extra}---\n\n${body}`;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=spec-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/spec-support.ts"],"sourcesContent":["import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, join } from 'node:path';\n\n/** A directory holding `files`, nested by their paths. */\nexport const directoryOf = (files: Record<string, string>): string => {\n const directory = mkdtempSync(join(tmpdir(), 'docs-engine-'));\n for (const [name, text] of Object.entries(files)) {\n mkdirSync(dirname(join(directory, name)), { recursive: true });\n writeFileSync(join(directory, name), text);\n }\n return directory;\n};\n\n/** A record in entifix's format. */\nexport const record = (\n number: number,\n body = '## Decision\\n\\nWe decide.\\n',\n area = 'platform',\n): string =>\n `# ${number}. Title ${number}\\n\\n- Status: Accepted\\n- Date: 2026-11-17\\n- Area: ${area}\\n- Read when: a thing breaks\\n\\n${body}`;\n\nexport const guide = (title: string, body: string, extra = ''): string =>\n `---\\ntitle: ${title}\\n${extra}---\\n\\n${body}`;\n"],"names":["mkdirSync","mkdtempSync","writeFileSync","tmpdir","dirname","join","directoryOf","files","directory","name","text","Object","entries","recursive","record","number","body","area","guide","title","extra"],"mappings":"AAAA,SAASA,SAAS,EAAEC,WAAW,EAAEC,aAAa,QAAQ,UAAU;AAChE,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,OAAO,EAAEC,IAAI,QAAQ,YAAY;AAE1C,wDAAwD,GACxD,OAAO,MAAMC,cAAc,CAACC;IAC1B,MAAMC,YAAYP,YAAYI,KAAKF,UAAU;IAC7C,KAAK,MAAM,CAACM,MAAMC,KAAK,IAAIC,OAAOC,OAAO,CAACL,OAAQ;QAChDP,UAAUI,QAAQC,KAAKG,WAAWC,QAAQ;YAAEI,WAAW;QAAK;QAC5DX,cAAcG,KAAKG,WAAWC,OAAOC;IACvC;IACA,OAAOF;AACT,EAAE;AAEF,kCAAkC,GAClC,OAAO,MAAMM,SAAS,CACpBC,QACAC,OAAO,6BAA6B,EACpCC,OAAO,UAAU,GAEjB,CAAC,EAAE,EAAEF,OAAO,QAAQ,EAAEA,OAAO,oDAAoD,EAAEE,KAAK,iCAAiC,EAAED,MAAM,CAAC;AAEpI,OAAO,MAAME,QAAQ,CAACC,OAAeH,MAAcI,QAAQ,EAAE,GAC3D,CAAC,YAAY,EAAED,MAAM,EAAE,EAAEC,MAAM,OAAO,EAAEJ,MAAM,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ThemeOption } from '@entifix/react-controls';
|
|
2
|
+
export interface DocsHeadProps {
|
|
3
|
+
/** The same registry `DocsRoot` is given. */
|
|
4
|
+
readonly themes: readonly ThemeOption[];
|
|
5
|
+
readonly defaultTheme?: string;
|
|
6
|
+
/** The palettes fumadocs should treat as dark. */
|
|
7
|
+
readonly darkPalettes: readonly string[];
|
|
8
|
+
readonly nonce?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The first paint of an exported page: the stored palette from entifix's
|
|
12
|
+
* `ThemeScript` — an export has no server to read the cookie — and the scheme
|
|
13
|
+
* that palette implies. Render it inside <head>, from a server component.
|
|
14
|
+
*/
|
|
15
|
+
export declare function DocsHead({ themes, defaultTheme, darkPalettes, nonce, }: DocsHeadProps): import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=head.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../src/ui/head.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,yBAAyB,CAAC;AAIxE,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,kDAAkD;IAClD,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,KAAK,GACN,EAAE,aAAa,+BAcf"}
|
package/dist/ui/head.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { ThemeScript } from '@entifix/react-controls';
|
|
4
|
+
import { schemeScript } from './scheme.js';
|
|
5
|
+
/**
|
|
6
|
+
* The first paint of an exported page: the stored palette from entifix's
|
|
7
|
+
* `ThemeScript` — an export has no server to read the cookie — and the scheme
|
|
8
|
+
* that palette implies. Render it inside <head>, from a server component.
|
|
9
|
+
*/ export function DocsHead({ themes, defaultTheme, darkPalettes, nonce }) {
|
|
10
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
11
|
+
children: [
|
|
12
|
+
/*#__PURE__*/ _jsx(ThemeScript, _extends({
|
|
13
|
+
themes: themes
|
|
14
|
+
}, defaultTheme === undefined ? {} : {
|
|
15
|
+
defaultTheme
|
|
16
|
+
}, nonce === undefined ? {} : {
|
|
17
|
+
nonce
|
|
18
|
+
})),
|
|
19
|
+
/*#__PURE__*/ _jsx("script", {
|
|
20
|
+
nonce: nonce,
|
|
21
|
+
dangerouslySetInnerHTML: {
|
|
22
|
+
__html: schemeScript(darkPalettes)
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=head.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/head.tsx"],"sourcesContent":["import { type ThemeOption, ThemeScript } from '@entifix/react-controls';\n\nimport { schemeScript } from './scheme.js';\n\nexport interface DocsHeadProps {\n /** The same registry `DocsRoot` is given. */\n readonly themes: readonly ThemeOption[];\n readonly defaultTheme?: string;\n /** The palettes fumadocs should treat as dark. */\n readonly darkPalettes: readonly string[];\n readonly nonce?: string;\n}\n\n/**\n * The first paint of an exported page: the stored palette from entifix's\n * `ThemeScript` — an export has no server to read the cookie — and the scheme\n * that palette implies. Render it inside <head>, from a server component.\n */\nexport function DocsHead({\n themes,\n defaultTheme,\n darkPalettes,\n nonce,\n}: DocsHeadProps) {\n return (\n <>\n <ThemeScript\n themes={themes}\n {...(defaultTheme === undefined ? {} : { defaultTheme })}\n {...(nonce === undefined ? {} : { nonce })}\n />\n <script\n nonce={nonce}\n dangerouslySetInnerHTML={{ __html: schemeScript(darkPalettes) }}\n />\n </>\n );\n}\n"],"names":["ThemeScript","schemeScript","DocsHead","themes","defaultTheme","darkPalettes","nonce","undefined","script","dangerouslySetInnerHTML","__html"],"mappings":";;AAAA,SAA2BA,WAAW,QAAQ,0BAA0B;AAExE,SAASC,YAAY,QAAQ,cAAc;AAW3C;;;;CAIC,GACD,OAAO,SAASC,SAAS,EACvBC,MAAM,EACNC,YAAY,EACZC,YAAY,EACZC,KAAK,EACS;IACd,qBACE;;0BACE,KAACN;gBACCG,QAAQA;eACHC,iBAAiBG,YAAY,CAAC,IAAI;gBAAEH;YAAa,GACjDE,UAAUC,YAAY,CAAC,IAAI;gBAAED;YAAM;0BAE1C,KAACE;gBACCF,OAAOA;gBACPG,yBAAyB;oBAAEC,QAAQT,aAAaI;gBAAc;;;;AAItE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { DocsHeadProps } from './head.js';
|
|
2
|
+
export { DocsHead } from './head.js';
|
|
3
|
+
export type { DocsLayoutProps } from './layout.js';
|
|
4
|
+
export { DocsLayout } from './layout.js';
|
|
5
|
+
export type { DocsPageProps } from './page.js';
|
|
6
|
+
export { docsMetadata, DocsPage } from './page.js';
|
|
7
|
+
export type { Pagefind } from './pagefind.js';
|
|
8
|
+
export { loadPagefind, toSortedResults } from './pagefind.js';
|
|
9
|
+
export type { DocsRootProps } from './root.js';
|
|
10
|
+
export { DocsRoot } from './root.js';
|
|
11
|
+
export { SCHEME_ATTRIBUTE, schemeOf, schemeScript } from './scheme.js';
|
|
12
|
+
export { useDocsTranslations } from './translations.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACnD,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { DocsHead } from './head.js';
|
|
2
|
+
export { DocsLayout } from './layout.js';
|
|
3
|
+
export { docsMetadata, DocsPage } from './page.js';
|
|
4
|
+
export { loadPagefind, toSortedResults } from './pagefind.js';
|
|
5
|
+
export { DocsRoot } from './root.js';
|
|
6
|
+
export { SCHEME_ATTRIBUTE, schemeOf, schemeScript } from './scheme.js';
|
|
7
|
+
export { useDocsTranslations } from './translations.js';
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/index.ts"],"sourcesContent":["export type { DocsHeadProps } from './head.js';\nexport { DocsHead } from './head.js';\nexport type { DocsLayoutProps } from './layout.js';\nexport { DocsLayout } from './layout.js';\nexport type { DocsPageProps } from './page.js';\nexport { docsMetadata, DocsPage } from './page.js';\nexport type { Pagefind } from './pagefind.js';\nexport { loadPagefind, toSortedResults } from './pagefind.js';\nexport type { DocsRootProps } from './root.js';\nexport { DocsRoot } from './root.js';\nexport { SCHEME_ATTRIBUTE, schemeOf, schemeScript } from './scheme.js';\nexport { useDocsTranslations } from './translations.js';\n"],"names":["DocsHead","DocsLayout","docsMetadata","DocsPage","loadPagefind","toSortedResults","DocsRoot","SCHEME_ATTRIBUTE","schemeOf","schemeScript","useDocsTranslations"],"mappings":"AACA,SAASA,QAAQ,QAAQ,YAAY;AAErC,SAASC,UAAU,QAAQ,cAAc;AAEzC,SAASC,YAAY,EAAEC,QAAQ,QAAQ,YAAY;AAEnD,SAASC,YAAY,EAAEC,eAAe,QAAQ,gBAAgB;AAE9D,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,gBAAgB,EAAEC,QAAQ,EAAEC,YAAY,QAAQ,cAAc;AACvE,SAASC,mBAAmB,QAAQ,oBAAoB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { DocsSite } from '../site.js';
|
|
3
|
+
export interface DocsLayoutProps {
|
|
4
|
+
readonly site: DocsSite;
|
|
5
|
+
/** The site's name in the header. */
|
|
6
|
+
readonly title: ReactNode;
|
|
7
|
+
readonly children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* fumadocs' docs layout over the site's page tree, with entifix's theme
|
|
11
|
+
* switcher in the sidebar's footer in place of fumadocs' own — which only knows
|
|
12
|
+
* light and dark, and would be a second owner of the palette.
|
|
13
|
+
*/
|
|
14
|
+
export declare function DocsLayout({ site, title, children }: DocsLayoutProps): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/ui/layout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,eAAe,+BAcpE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeSwitcher } from '@entifix/react-controls';
|
|
3
|
+
import { DocsLayout as FumadocsLayout } from 'fumadocs-ui/layouts/docs';
|
|
4
|
+
import { SkipLink } from './skip-link.js';
|
|
5
|
+
/**
|
|
6
|
+
* fumadocs' docs layout over the site's page tree, with entifix's theme
|
|
7
|
+
* switcher in the sidebar's footer in place of fumadocs' own — which only knows
|
|
8
|
+
* light and dark, and would be a second owner of the palette.
|
|
9
|
+
*/ export function DocsLayout({ site, title, children }) {
|
|
10
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
11
|
+
children: [
|
|
12
|
+
/*#__PURE__*/ _jsx(SkipLink, {}),
|
|
13
|
+
/*#__PURE__*/ _jsx(FumadocsLayout, {
|
|
14
|
+
tree: site.pageTree,
|
|
15
|
+
nav: {
|
|
16
|
+
title
|
|
17
|
+
},
|
|
18
|
+
themeSwitch: {
|
|
19
|
+
enabled: false
|
|
20
|
+
},
|
|
21
|
+
sidebar: {
|
|
22
|
+
footer: /*#__PURE__*/ _jsx(ThemeSwitcher, {})
|
|
23
|
+
},
|
|
24
|
+
children: children
|
|
25
|
+
})
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/layout.tsx"],"sourcesContent":["import { ThemeSwitcher } from '@entifix/react-controls';\nimport { DocsLayout as FumadocsLayout } from 'fumadocs-ui/layouts/docs';\nimport type { ReactNode } from 'react';\n\nimport type { DocsSite } from '../site.js';\nimport { SkipLink } from './skip-link.js';\n\nexport interface DocsLayoutProps {\n readonly site: DocsSite;\n /** The site's name in the header. */\n readonly title: ReactNode;\n readonly children: ReactNode;\n}\n\n/**\n * fumadocs' docs layout over the site's page tree, with entifix's theme\n * switcher in the sidebar's footer in place of fumadocs' own — which only knows\n * light and dark, and would be a second owner of the palette.\n */\nexport function DocsLayout({ site, title, children }: DocsLayoutProps) {\n return (\n <>\n <SkipLink />\n <FumadocsLayout\n tree={site.pageTree}\n nav={{ title }}\n themeSwitch={{ enabled: false }}\n sidebar={{ footer: <ThemeSwitcher /> }}\n >\n {children}\n </FumadocsLayout>\n </>\n );\n}\n"],"names":["ThemeSwitcher","DocsLayout","FumadocsLayout","SkipLink","site","title","children","tree","pageTree","nav","themeSwitch","enabled","sidebar","footer"],"mappings":";AAAA,SAASA,aAAa,QAAQ,0BAA0B;AACxD,SAASC,cAAcC,cAAc,QAAQ,2BAA2B;AAIxE,SAASC,QAAQ,QAAQ,iBAAiB;AAS1C;;;;CAIC,GACD,OAAO,SAASF,WAAW,EAAEG,IAAI,EAAEC,KAAK,EAAEC,QAAQ,EAAmB;IACnE,qBACE;;0BACE,KAACH;0BACD,KAACD;gBACCK,MAAMH,KAAKI,QAAQ;gBACnBC,KAAK;oBAAEJ;gBAAM;gBACbK,aAAa;oBAAEC,SAAS;gBAAM;gBAC9BC,SAAS;oBAAEC,sBAAQ,KAACb;gBAAiB;0BAEpCM;;;;AAIT"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { DocsSite } from '../site.js';
|
|
3
|
+
export interface DocsPageProps {
|
|
4
|
+
readonly site: DocsSite;
|
|
5
|
+
/** The route's catch-all segment. */
|
|
6
|
+
readonly slugs: readonly string[] | undefined;
|
|
7
|
+
/** Elements to render differently, keyed by tag name. */
|
|
8
|
+
readonly components?: Readonly<Record<string, ComponentType<never>>>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* One page of the site: its title, its description and its body, rendered on
|
|
12
|
+
* the server at build time. The article carries `data-pagefind-body`, so the
|
|
13
|
+
* search index holds what a page says and not its chrome (entifix #276).
|
|
14
|
+
*/
|
|
15
|
+
export declare function DocsPage({ site, slugs, components }: DocsPageProps): Promise<import("react").JSX.Element>;
|
|
16
|
+
/** A page's `<title>` and description, for `generateMetadata`. */
|
|
17
|
+
export declare const docsMetadata: (site: DocsSite, slugs: readonly string[] | undefined) => {
|
|
18
|
+
description?: string | undefined;
|
|
19
|
+
title: string;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/ui/page.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC9C,yDAAyD;IACzD,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CACtE;AAuBD;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,aAAa,wCAyBxE;AAED,kEAAkE;AAClE,eAAO,MAAM,YAAY,GACvB,MAAM,QAAQ,EACd,OAAO,SAAS,MAAM,EAAE,GAAG,SAAS;;;CAUrC,CAAC"}
|
package/dist/ui/page.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import defaultMdxComponents from 'fumadocs-ui/mdx';
|
|
4
|
+
import { DocsBody, DocsDescription, DocsPage as FumadocsPage, DocsTitle } from 'fumadocs-ui/page';
|
|
5
|
+
import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
|
|
6
|
+
import { notFound } from 'next/navigation';
|
|
7
|
+
import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
/**
|
|
9
|
+
* A heading with no copy-link button inside it. fumadocs' own puts a button in
|
|
10
|
+
* every heading, and Pagefind indexed its label as part of the heading's text —
|
|
11
|
+
* every search result read "…Copy the link to this section". The table of
|
|
12
|
+
* contents already links each heading.
|
|
13
|
+
*/ const plainHeading = (Tag)=>function Heading(props) {
|
|
14
|
+
return /*#__PURE__*/ _jsx(Tag, _extends({}, props, {
|
|
15
|
+
className: "scroll-m-28"
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
const HEADINGS = {
|
|
19
|
+
h2: plainHeading('h2'),
|
|
20
|
+
h3: plainHeading('h3'),
|
|
21
|
+
h4: plainHeading('h4'),
|
|
22
|
+
h5: plainHeading('h5'),
|
|
23
|
+
h6: plainHeading('h6')
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* One page of the site: its title, its description and its body, rendered on
|
|
27
|
+
* the server at build time. The article carries `data-pagefind-body`, so the
|
|
28
|
+
* search index holds what a page says and not its chrome (entifix #276).
|
|
29
|
+
*/ export async function DocsPage({ site, slugs, components }) {
|
|
30
|
+
const page = site.page(slugs);
|
|
31
|
+
if (page === undefined) notFound();
|
|
32
|
+
const { tree, toc } = await site.render(page.data);
|
|
33
|
+
const body = toJsxRuntime(tree, {
|
|
34
|
+
Fragment,
|
|
35
|
+
jsx,
|
|
36
|
+
jsxs,
|
|
37
|
+
components: _extends({}, defaultMdxComponents, HEADINGS, components)
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/ _jsx(FumadocsPage, {
|
|
40
|
+
toc: [
|
|
41
|
+
...toc
|
|
42
|
+
],
|
|
43
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
44
|
+
"data-pagefind-body": "",
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ _jsx(DocsTitle, {
|
|
47
|
+
"data-pagefind-meta": "title",
|
|
48
|
+
children: page.data.title
|
|
49
|
+
}),
|
|
50
|
+
page.data.description === undefined ? null : /*#__PURE__*/ _jsx(DocsDescription, {
|
|
51
|
+
children: page.data.description
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ _jsx(DocsBody, {
|
|
54
|
+
children: body
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** A page's `<title>` and description, for `generateMetadata`. */ export const docsMetadata = (site, slugs)=>{
|
|
61
|
+
const page = site.page(slugs);
|
|
62
|
+
if (page === undefined) notFound();
|
|
63
|
+
return _extends({
|
|
64
|
+
title: page.data.title
|
|
65
|
+
}, page.data.description === undefined ? {} : {
|
|
66
|
+
description: page.data.description
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/page.tsx"],"sourcesContent":["import defaultMdxComponents from 'fumadocs-ui/mdx';\nimport {\n DocsBody,\n DocsDescription,\n DocsPage as FumadocsPage,\n DocsTitle,\n} from 'fumadocs-ui/page';\nimport { toJsxRuntime } from 'hast-util-to-jsx-runtime';\nimport { notFound } from 'next/navigation';\nimport type { ComponentProps, ComponentType } from 'react';\nimport { Fragment, jsx, jsxs } from 'react/jsx-runtime';\n\nimport type { DocsSite } from '../site.js';\n\nexport interface DocsPageProps {\n readonly site: DocsSite;\n /** The route's catch-all segment. */\n readonly slugs: readonly string[] | undefined;\n /** Elements to render differently, keyed by tag name. */\n readonly components?: Readonly<Record<string, ComponentType<never>>>;\n}\n\ntype HeadingTag = 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n\n/**\n * A heading with no copy-link button inside it. fumadocs' own puts a button in\n * every heading, and Pagefind indexed its label as part of the heading's text —\n * every search result read \"…Copy the link to this section\". The table of\n * contents already links each heading.\n */\nconst plainHeading = (Tag: HeadingTag) =>\n function Heading(props: ComponentProps<HeadingTag>) {\n return <Tag {...props} className=\"scroll-m-28\" />;\n };\n\nconst HEADINGS = {\n h2: plainHeading('h2'),\n h3: plainHeading('h3'),\n h4: plainHeading('h4'),\n h5: plainHeading('h5'),\n h6: plainHeading('h6'),\n};\n\n/**\n * One page of the site: its title, its description and its body, rendered on\n * the server at build time. The article carries `data-pagefind-body`, so the\n * search index holds what a page says and not its chrome (entifix #276).\n */\nexport async function DocsPage({ site, slugs, components }: DocsPageProps) {\n const page = site.page(slugs);\n if (page === undefined) notFound();\n const { tree, toc } = await site.render(page.data);\n const body = toJsxRuntime(tree, {\n Fragment,\n jsx,\n jsxs,\n components: {\n ...defaultMdxComponents,\n ...HEADINGS,\n ...components,\n } as never,\n });\n return (\n <FumadocsPage toc={[...toc]}>\n <div data-pagefind-body=\"\">\n <DocsTitle data-pagefind-meta=\"title\">{page.data.title}</DocsTitle>\n {page.data.description === undefined ? null : (\n <DocsDescription>{page.data.description}</DocsDescription>\n )}\n <DocsBody>{body}</DocsBody>\n </div>\n </FumadocsPage>\n );\n}\n\n/** A page's `<title>` and description, for `generateMetadata`. */\nexport const docsMetadata = (\n site: DocsSite,\n slugs: readonly string[] | undefined,\n) => {\n const page = site.page(slugs);\n if (page === undefined) notFound();\n return {\n title: page.data.title,\n ...(page.data.description === undefined\n ? {}\n : { description: page.data.description }),\n };\n};\n"],"names":["defaultMdxComponents","DocsBody","DocsDescription","DocsPage","FumadocsPage","DocsTitle","toJsxRuntime","notFound","Fragment","jsx","jsxs","plainHeading","Tag","Heading","props","className","HEADINGS","h2","h3","h4","h5","h6","site","slugs","components","page","undefined","tree","toc","render","data","body","div","data-pagefind-body","data-pagefind-meta","title","description","docsMetadata"],"mappings":";;AAAA,OAAOA,0BAA0B,kBAAkB;AACnD,SACEC,QAAQ,EACRC,eAAe,EACfC,YAAYC,YAAY,EACxBC,SAAS,QACJ,mBAAmB;AAC1B,SAASC,YAAY,QAAQ,2BAA2B;AACxD,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,SAASC,QAAQ,EAAEC,GAAG,EAAEC,IAAI,QAAQ,oBAAoB;AAcxD;;;;;CAKC,GACD,MAAMC,eAAe,CAACC,MACpB,SAASC,QAAQC,KAAiC;QAChD,qBAAO,KAACF,kBAAQE;YAAOC,WAAU;;IACnC;AAEF,MAAMC,WAAW;IACfC,IAAIN,aAAa;IACjBO,IAAIP,aAAa;IACjBQ,IAAIR,aAAa;IACjBS,IAAIT,aAAa;IACjBU,IAAIV,aAAa;AACnB;AAEA;;;;CAIC,GACD,OAAO,eAAeR,SAAS,EAAEmB,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAAiB;IACvE,MAAMC,OAAOH,KAAKG,IAAI,CAACF;IACvB,IAAIE,SAASC,WAAWnB;IACxB,MAAM,EAAEoB,IAAI,EAAEC,GAAG,EAAE,GAAG,MAAMN,KAAKO,MAAM,CAACJ,KAAKK,IAAI;IACjD,MAAMC,OAAOzB,aAAaqB,MAAM;QAC9BnB;QACAC;QACAC;QACAc,YAAY,aACPxB,sBACAgB,UACAQ;IAEP;IACA,qBACE,KAACpB;QAAawB,KAAK;eAAIA;SAAI;kBACzB,cAAA,MAACI;YAAIC,sBAAmB;;8BACtB,KAAC5B;oBAAU6B,sBAAmB;8BAAST,KAAKK,IAAI,CAACK,KAAK;;gBACrDV,KAAKK,IAAI,CAACM,WAAW,KAAKV,YAAY,qBACrC,KAACxB;8BAAiBuB,KAAKK,IAAI,CAACM,WAAW;;8BAEzC,KAACnC;8BAAU8B;;;;;AAInB;AAEA,gEAAgE,GAChE,OAAO,MAAMM,eAAe,CAC1Bf,MACAC;IAEA,MAAME,OAAOH,KAAKG,IAAI,CAACF;IACvB,IAAIE,SAASC,WAAWnB;IACxB,OAAO;QACL4B,OAAOV,KAAKK,IAAI,CAACK,KAAK;OAClBV,KAAKK,IAAI,CAACM,WAAW,KAAKV,YAC1B,CAAC,IACD;QAAEU,aAAaX,KAAKK,IAAI,CAACM,WAAW;IAAC;AAE7C,EAAE"}
|