fumadocs-core 14.1.0 → 14.2.0
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/dist/chunk-SHGL6VBO.js +33 -0
- package/dist/mdx-plugins/index.d.ts +4 -30
- package/dist/mdx-plugins/index.js +58 -53
- package/dist/orama-cloud-QNHGN6SO.js +50 -0
- package/dist/remark-heading-BPCoYwjn.d.ts +31 -0
- package/dist/search/client.d.ts +10 -2
- package/dist/search/client.js +6 -2
- package/dist/search/orama-cloud.d.ts +76 -0
- package/dist/search/orama-cloud.js +52 -0
- package/dist/source/index.js +48 -65
- package/package.json +12 -3
- package/dist/chunk-UWEEHUJV.js +0 -12
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/utils/path.ts
|
|
2
|
+
function splitPath(path) {
|
|
3
|
+
return path.split("/").filter((p) => p.length > 0);
|
|
4
|
+
}
|
|
5
|
+
function resolvePath(from, join) {
|
|
6
|
+
const v1 = splitPath(from), v2 = splitPath(join);
|
|
7
|
+
while (v2.length > 0) {
|
|
8
|
+
switch (v2[0]) {
|
|
9
|
+
case "..":
|
|
10
|
+
v1.pop();
|
|
11
|
+
break;
|
|
12
|
+
case ".":
|
|
13
|
+
break;
|
|
14
|
+
default:
|
|
15
|
+
v1.push(v2[0]);
|
|
16
|
+
}
|
|
17
|
+
v2.shift();
|
|
18
|
+
}
|
|
19
|
+
return v1.join("/");
|
|
20
|
+
}
|
|
21
|
+
function slash(path) {
|
|
22
|
+
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
|
23
|
+
if (isExtendedLengthPath) {
|
|
24
|
+
return path;
|
|
25
|
+
}
|
|
26
|
+
return path.replaceAll("\\", "/");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
splitPath,
|
|
31
|
+
resolvePath,
|
|
32
|
+
slash
|
|
33
|
+
};
|
|
@@ -3,8 +3,9 @@ import { Root } from 'hast';
|
|
|
3
3
|
import { RehypeShikiOptions } from '@shikijs/rehype';
|
|
4
4
|
import { Processor, Transformer } from 'unified';
|
|
5
5
|
import { ShikiTransformer } from 'shiki';
|
|
6
|
-
import { Root as Root$1
|
|
6
|
+
import { Root as Root$1 } from 'mdast';
|
|
7
7
|
export { a as StructureOptions, S as StructuredData, r as remarkStructure, s as structure } from '../remark-structure-mP51W1AN.js';
|
|
8
|
+
export { R as RemarkHeadingOptions, r as remarkHeading } from '../remark-heading-BPCoYwjn.js';
|
|
8
9
|
import 'unist-util-visit';
|
|
9
10
|
|
|
10
11
|
interface CodeBlockIcon {
|
|
@@ -52,7 +53,7 @@ declare function transformerTab(): ShikiTransformer;
|
|
|
52
53
|
|
|
53
54
|
interface RemarkImageOptions {
|
|
54
55
|
/**
|
|
55
|
-
* Directory to resolve absolute image paths
|
|
56
|
+
* Directory or base URL to resolve absolute image paths
|
|
56
57
|
*/
|
|
57
58
|
publicDir?: string;
|
|
58
59
|
/**
|
|
@@ -87,33 +88,6 @@ interface RemarkImageOptions {
|
|
|
87
88
|
*/
|
|
88
89
|
declare function remarkImage({ placeholder, external, useImport, publicDir, }?: RemarkImageOptions): Transformer<Root$1, Root$1>;
|
|
89
90
|
|
|
90
|
-
declare module 'mdast' {
|
|
91
|
-
interface HeadingData extends Data {
|
|
92
|
-
hProperties?: {
|
|
93
|
-
id?: string;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
interface RemarkHeadingOptions {
|
|
98
|
-
slug?: (root: Root$1, heading: Heading, text: string) => string;
|
|
99
|
-
/**
|
|
100
|
-
* Allow custom headings ids
|
|
101
|
-
*
|
|
102
|
-
* @defaultValue true
|
|
103
|
-
*/
|
|
104
|
-
customId?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Attach an array of `TOCItemType` to `file.data.toc`
|
|
107
|
-
*
|
|
108
|
-
* @defaultValue true
|
|
109
|
-
*/
|
|
110
|
-
generateToc?: boolean;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Add heading ids and extract TOC
|
|
114
|
-
*/
|
|
115
|
-
declare function remarkHeading({ slug: defaultSlug, customId, generateToc, }?: RemarkHeadingOptions): Transformer<Root$1, Root$1>;
|
|
116
|
-
|
|
117
91
|
interface RemarkAdmonitionOptions {
|
|
118
92
|
tag?: string;
|
|
119
93
|
types?: string[];
|
|
@@ -139,4 +113,4 @@ interface RehypeTocOptions {
|
|
|
139
113
|
}
|
|
140
114
|
declare function rehypeToc(this: Processor, { exportToc }?: RehypeTocOptions): Transformer<Root, Root>;
|
|
141
115
|
|
|
142
|
-
export { type CodeBlockIcon, type RehypeCodeOptions, type RehypeTocOptions, type RemarkAdmonitionOptions, type
|
|
116
|
+
export { type CodeBlockIcon, type RehypeCodeOptions, type RehypeTocOptions, type RemarkAdmonitionOptions, type RemarkImageOptions, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkImage, transformerIcon, transformerTab };
|
|
@@ -2,13 +2,14 @@ import {
|
|
|
2
2
|
flattenNode,
|
|
3
3
|
remarkHeading
|
|
4
4
|
} from "../chunk-4MNUWZIW.js";
|
|
5
|
+
import {
|
|
6
|
+
resolvePath,
|
|
7
|
+
slash
|
|
8
|
+
} from "../chunk-SHGL6VBO.js";
|
|
5
9
|
import {
|
|
6
10
|
createStyleTransformer,
|
|
7
11
|
defaultThemes
|
|
8
12
|
} from "../chunk-7CSWJQ5H.js";
|
|
9
|
-
import {
|
|
10
|
-
slash
|
|
11
|
-
} from "../chunk-UWEEHUJV.js";
|
|
12
13
|
import "../chunk-MLKGABMK.js";
|
|
13
14
|
|
|
14
15
|
// src/mdx-plugins/index.ts
|
|
@@ -550,57 +551,58 @@ function remarkImage({
|
|
|
550
551
|
const promises = [];
|
|
551
552
|
function getImportPath(src) {
|
|
552
553
|
if (!src.startsWith("/")) return src;
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
path.join(publicDir, src)
|
|
557
|
-
);
|
|
554
|
+
const to = path.join(publicDir, src);
|
|
555
|
+
if (file.dirname) {
|
|
556
|
+
const relative = slash(path.relative(file.dirname, to));
|
|
558
557
|
return relative.startsWith("./") ? relative : `./${relative}`;
|
|
559
558
|
}
|
|
560
|
-
return
|
|
559
|
+
return slash(to);
|
|
561
560
|
}
|
|
562
561
|
visit(tree, "image", (node) => {
|
|
563
|
-
const
|
|
564
|
-
if (!
|
|
565
|
-
const isExternal = EXTERNAL_URL_REGEX.test(
|
|
562
|
+
const url = decodeURI(node.url);
|
|
563
|
+
if (!url) return;
|
|
564
|
+
const isExternal = EXTERNAL_URL_REGEX.test(url);
|
|
566
565
|
if (isExternal && external || !useImport) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
566
|
+
const task = getImageSize(url, publicDir).then((size) => {
|
|
567
|
+
if (!size.width || !size.height) return;
|
|
568
|
+
Object.assign(node, {
|
|
569
|
+
type: "mdxJsxFlowElement",
|
|
570
|
+
name: "img",
|
|
571
|
+
attributes: [
|
|
572
|
+
{
|
|
573
|
+
type: "mdxJsxAttribute",
|
|
574
|
+
name: "alt",
|
|
575
|
+
value: node.alt ?? "image"
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
type: "mdxJsxAttribute",
|
|
579
|
+
name: "src",
|
|
580
|
+
value: url
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
type: "mdxJsxAttribute",
|
|
584
|
+
name: "width",
|
|
585
|
+
value: size.width.toString()
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
type: "mdxJsxAttribute",
|
|
589
|
+
name: "height",
|
|
590
|
+
value: size.height.toString()
|
|
591
|
+
}
|
|
592
|
+
]
|
|
593
|
+
});
|
|
594
|
+
}).catch(() => {
|
|
595
|
+
console.error(
|
|
596
|
+
`[Remark Image] Failed obtain image size for ${url} with public directory ${publicDir}`
|
|
597
|
+
);
|
|
598
|
+
});
|
|
599
|
+
promises.push(task);
|
|
598
600
|
} else if (!isExternal) {
|
|
599
601
|
const variableName = `__img${importsToInject.length.toString()}`;
|
|
600
|
-
const hasBlur = placeholder === "blur" && VALID_BLUR_EXT.some((ext) =>
|
|
602
|
+
const hasBlur = placeholder === "blur" && VALID_BLUR_EXT.some((ext) => url.endsWith(ext));
|
|
601
603
|
importsToInject.push({
|
|
602
604
|
variableName,
|
|
603
|
-
importPath:
|
|
605
|
+
importPath: getImportPath(url)
|
|
604
606
|
});
|
|
605
607
|
Object.assign(node, {
|
|
606
608
|
type: "mdxJsxFlowElement",
|
|
@@ -665,17 +667,20 @@ function remarkImage({
|
|
|
665
667
|
}
|
|
666
668
|
};
|
|
667
669
|
}
|
|
668
|
-
function resolveSrc(src, dir) {
|
|
669
|
-
return src.startsWith("/") || !path.isAbsolute(src) ? path.join(dir, src) : src;
|
|
670
|
-
}
|
|
671
670
|
async function getImageSize(src, dir) {
|
|
671
|
+
const isRelative = src.startsWith("/") || !path.isAbsolute(src);
|
|
672
|
+
let url;
|
|
672
673
|
if (EXTERNAL_URL_REGEX.test(src)) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
);
|
|
674
|
+
url = src;
|
|
675
|
+
} else if (EXTERNAL_URL_REGEX.test(dir) && isRelative) {
|
|
676
|
+
const base = new URL(dir);
|
|
677
|
+
base.pathname = resolvePath(base.pathname, src);
|
|
678
|
+
url = base.toString();
|
|
679
|
+
} else {
|
|
680
|
+
return sizeOf(isRelative ? path.join(dir, src) : src);
|
|
677
681
|
}
|
|
678
|
-
|
|
682
|
+
const buffer = await fetch(url).then((res) => res.arrayBuffer());
|
|
683
|
+
return sizeOf(new Uint8Array(buffer));
|
|
679
684
|
}
|
|
680
685
|
|
|
681
686
|
// src/mdx-plugins/remark-structure.ts
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
removeUndefined
|
|
3
|
+
} from "./chunk-2V6SCS43.js";
|
|
4
|
+
import "./chunk-MLKGABMK.js";
|
|
5
|
+
|
|
6
|
+
// src/search/client/orama-cloud.ts
|
|
7
|
+
async function searchDocs(query, tag, options) {
|
|
8
|
+
const { client, params: extraParams = {} } = options;
|
|
9
|
+
const params = {
|
|
10
|
+
...extraParams,
|
|
11
|
+
term: query,
|
|
12
|
+
where: removeUndefined({
|
|
13
|
+
tag,
|
|
14
|
+
...extraParams.where
|
|
15
|
+
}),
|
|
16
|
+
groupBy: {
|
|
17
|
+
properties: ["page_id"],
|
|
18
|
+
maxResult: 7,
|
|
19
|
+
...extraParams.groupBy
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const result = await client.search(params);
|
|
23
|
+
if (!result) return [];
|
|
24
|
+
const list = [];
|
|
25
|
+
for (const item of result.groups ?? []) {
|
|
26
|
+
let addedHead = false;
|
|
27
|
+
for (const hit of item.result) {
|
|
28
|
+
const doc = hit.document;
|
|
29
|
+
if (!addedHead) {
|
|
30
|
+
list.push({
|
|
31
|
+
id: doc.page_id,
|
|
32
|
+
type: "page",
|
|
33
|
+
content: doc.title,
|
|
34
|
+
url: doc.url
|
|
35
|
+
});
|
|
36
|
+
addedHead = true;
|
|
37
|
+
}
|
|
38
|
+
list.push({
|
|
39
|
+
id: doc.id,
|
|
40
|
+
content: doc.content,
|
|
41
|
+
type: doc.content === doc.section ? "heading" : "text",
|
|
42
|
+
url: doc.section_id ? `${doc.url}#${doc.section_id}` : doc.url
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return list;
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
searchDocs
|
|
50
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Root, Heading } from 'mdast';
|
|
2
|
+
import { Transformer } from 'unified';
|
|
3
|
+
|
|
4
|
+
declare module 'mdast' {
|
|
5
|
+
interface HeadingData extends Data {
|
|
6
|
+
hProperties?: {
|
|
7
|
+
id?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
interface RemarkHeadingOptions {
|
|
12
|
+
slug?: (root: Root, heading: Heading, text: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Allow custom headings ids
|
|
15
|
+
*
|
|
16
|
+
* @defaultValue true
|
|
17
|
+
*/
|
|
18
|
+
customId?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Attach an array of `TOCItemType` to `file.data.toc`
|
|
21
|
+
*
|
|
22
|
+
* @defaultValue true
|
|
23
|
+
*/
|
|
24
|
+
generateToc?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Add heading ids and extract TOC
|
|
28
|
+
*/
|
|
29
|
+
declare function remarkHeading({ slug: defaultSlug, customId, generateToc, }?: RemarkHeadingOptions): Transformer<Root, Root>;
|
|
30
|
+
|
|
31
|
+
export { type RemarkHeadingOptions as R, remarkHeading as r };
|
package/dist/search/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { S as SortedResult } from '../types-Ch8gnVgO.js';
|
|
2
2
|
import { SearchOptions } from '@algolia/client-search';
|
|
3
3
|
import { SearchIndex } from 'algoliasearch/lite';
|
|
4
|
+
import { OramaClient, ClientSearchParams } from '@oramacloud/client';
|
|
4
5
|
|
|
5
6
|
interface FetchOptions {
|
|
6
7
|
/**
|
|
@@ -20,6 +21,11 @@ interface AlgoliaOptions extends SearchOptions {
|
|
|
20
21
|
index: SearchIndex;
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
interface OramaCloudOptions {
|
|
25
|
+
client: OramaClient;
|
|
26
|
+
params?: ClientSearchParams;
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
interface UseDocsSearch {
|
|
24
30
|
search: string;
|
|
25
31
|
setSearch: (v: string) => void;
|
|
@@ -35,7 +41,9 @@ type Client = ({
|
|
|
35
41
|
type: 'static';
|
|
36
42
|
} & StaticOptions) | ({
|
|
37
43
|
type: 'algolia';
|
|
38
|
-
} & AlgoliaOptions)
|
|
44
|
+
} & AlgoliaOptions) | ({
|
|
45
|
+
type: 'orama-cloud';
|
|
46
|
+
} & OramaCloudOptions);
|
|
39
47
|
/**
|
|
40
48
|
* @param client - search client
|
|
41
49
|
* @param locale - Filter with locale
|
|
@@ -46,4 +54,4 @@ type Client = ({
|
|
|
46
54
|
*/
|
|
47
55
|
declare function useDocsSearch(client: Client, locale?: string, tag?: string, delayMs?: number, allowEmpty?: boolean, key?: string): UseDocsSearch;
|
|
48
56
|
|
|
49
|
-
export { useDocsSearch };
|
|
57
|
+
export { type AlgoliaOptions, type FetchOptions, type OramaCloudOptions, type StaticOptions, useDocsSearch };
|
package/dist/search/client.js
CHANGED
|
@@ -33,8 +33,8 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
|
|
|
33
33
|
const debouncedValue = useDebounce(search, delayMs);
|
|
34
34
|
const onStart = useRef2();
|
|
35
35
|
const cacheKey = useMemo(() => {
|
|
36
|
-
return key ?? JSON.stringify([client, debouncedValue, locale, tag]);
|
|
37
|
-
}, [client, debouncedValue, locale, tag, key]);
|
|
36
|
+
return key ?? JSON.stringify([client.type, debouncedValue, locale, tag]);
|
|
37
|
+
}, [client.type, debouncedValue, locale, tag, key]);
|
|
38
38
|
useOnChange(cacheKey, () => {
|
|
39
39
|
const cached = cache.get(cacheKey);
|
|
40
40
|
if (onStart.current) {
|
|
@@ -63,6 +63,10 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
|
|
|
63
63
|
const { searchDocs } = await import("../algolia-NTWLS6J3.js");
|
|
64
64
|
return searchDocs(index, debouncedValue, tag, rest);
|
|
65
65
|
}
|
|
66
|
+
if (client.type === "orama-cloud") {
|
|
67
|
+
const { searchDocs } = await import("../orama-cloud-QNHGN6SO.js");
|
|
68
|
+
return searchDocs(debouncedValue, tag, client);
|
|
69
|
+
}
|
|
66
70
|
const { createStaticClient } = await import("../static-5GPJ7RUY.js");
|
|
67
71
|
if (!staticClient) staticClient = createStaticClient(client);
|
|
68
72
|
return staticClient.search(debouncedValue, locale, tag);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { CloudManager } from '@oramacloud/client';
|
|
2
|
+
import { S as StructuredData } from '../remark-structure-mP51W1AN.js';
|
|
3
|
+
import '../remark-heading-BPCoYwjn.js';
|
|
4
|
+
import 'mdast';
|
|
5
|
+
import 'unified';
|
|
6
|
+
import 'unist-util-visit';
|
|
7
|
+
|
|
8
|
+
interface SyncOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Index name to sync
|
|
11
|
+
*/
|
|
12
|
+
index: string;
|
|
13
|
+
documents: OramaDocument[];
|
|
14
|
+
/**
|
|
15
|
+
* Deploy changes
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue true
|
|
18
|
+
*/
|
|
19
|
+
autoDeploy?: boolean;
|
|
20
|
+
}
|
|
21
|
+
type I18nSyncOptions = Omit<SyncOptions, 'index' | 'documents'> & {
|
|
22
|
+
/**
|
|
23
|
+
* Indexes to sync.
|
|
24
|
+
*
|
|
25
|
+
* Pairs of `locale`-`index`.
|
|
26
|
+
**/
|
|
27
|
+
indexes: Record<string, string>;
|
|
28
|
+
documents: {
|
|
29
|
+
locale: string;
|
|
30
|
+
items: OramaDocument[];
|
|
31
|
+
}[];
|
|
32
|
+
};
|
|
33
|
+
interface OramaDocument {
|
|
34
|
+
/**
|
|
35
|
+
* The ID of document, must be unique
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
title: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
/**
|
|
41
|
+
* URL to the page
|
|
42
|
+
*/
|
|
43
|
+
url: string;
|
|
44
|
+
structured: StructuredData;
|
|
45
|
+
/**
|
|
46
|
+
* Tag to filter results
|
|
47
|
+
*/
|
|
48
|
+
tag?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Data to be added to each section index
|
|
51
|
+
*/
|
|
52
|
+
extra_data?: object;
|
|
53
|
+
}
|
|
54
|
+
interface OramaIndex {
|
|
55
|
+
id: string;
|
|
56
|
+
title: string;
|
|
57
|
+
url: string;
|
|
58
|
+
tag?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The id of page, used for `group by`
|
|
61
|
+
*/
|
|
62
|
+
page_id: string;
|
|
63
|
+
/**
|
|
64
|
+
* Heading content
|
|
65
|
+
*/
|
|
66
|
+
section?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Heading (anchor) id
|
|
69
|
+
*/
|
|
70
|
+
section_id?: string;
|
|
71
|
+
content: string;
|
|
72
|
+
}
|
|
73
|
+
declare function sync(cloudManager: CloudManager, options: SyncOptions): Promise<void>;
|
|
74
|
+
declare function syncI18n(cloudManager: CloudManager, options: I18nSyncOptions): Promise<void>;
|
|
75
|
+
|
|
76
|
+
export { type I18nSyncOptions, type OramaDocument, type OramaIndex, type SyncOptions, sync, syncI18n };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import "../chunk-MLKGABMK.js";
|
|
2
|
+
|
|
3
|
+
// src/search/orama-cloud.ts
|
|
4
|
+
async function sync(cloudManager, options) {
|
|
5
|
+
const { autoDeploy = true } = options;
|
|
6
|
+
const index = cloudManager.index(options.index);
|
|
7
|
+
await index.snapshot(options.documents.flatMap(toIndex));
|
|
8
|
+
if (autoDeploy) await index.deploy();
|
|
9
|
+
}
|
|
10
|
+
async function syncI18n(cloudManager, options) {
|
|
11
|
+
const { autoDeploy = true } = options;
|
|
12
|
+
const tasks = options.documents.map(async (document) => {
|
|
13
|
+
const index = cloudManager.index(options.indexes[document.locale]);
|
|
14
|
+
await index.snapshot(document.items.flatMap(toIndex));
|
|
15
|
+
if (autoDeploy) await index.deploy();
|
|
16
|
+
});
|
|
17
|
+
await Promise.all(tasks);
|
|
18
|
+
}
|
|
19
|
+
function toIndex(page) {
|
|
20
|
+
let id = 0;
|
|
21
|
+
const indexes = [];
|
|
22
|
+
const scannedHeadings = /* @__PURE__ */ new Set();
|
|
23
|
+
function createIndex(section, sectionId, content) {
|
|
24
|
+
return {
|
|
25
|
+
id: `${page.id}-${(id++).toString()}`,
|
|
26
|
+
title: page.title,
|
|
27
|
+
url: page.url,
|
|
28
|
+
page_id: page.id,
|
|
29
|
+
tag: page.tag,
|
|
30
|
+
section,
|
|
31
|
+
section_id: sectionId,
|
|
32
|
+
content,
|
|
33
|
+
...page.extra_data
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (page.description)
|
|
37
|
+
indexes.push(createIndex(void 0, void 0, page.description));
|
|
38
|
+
page.structured.contents.forEach((p) => {
|
|
39
|
+
const heading = p.heading ? page.structured.headings.find((h) => p.heading === h.id) : null;
|
|
40
|
+
const index = createIndex(heading?.content, heading?.id, p.content);
|
|
41
|
+
if (heading && !scannedHeadings.has(heading.id)) {
|
|
42
|
+
scannedHeadings.add(heading.id);
|
|
43
|
+
indexes.push(createIndex(heading.content, heading.id, heading.content));
|
|
44
|
+
}
|
|
45
|
+
indexes.push(index);
|
|
46
|
+
});
|
|
47
|
+
return indexes;
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
sync,
|
|
51
|
+
syncI18n
|
|
52
|
+
};
|
package/dist/source/index.js
CHANGED
|
@@ -2,75 +2,14 @@ import {
|
|
|
2
2
|
removeUndefined
|
|
3
3
|
} from "../chunk-2V6SCS43.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
resolvePath,
|
|
6
|
+
slash,
|
|
7
|
+
splitPath
|
|
8
|
+
} from "../chunk-SHGL6VBO.js";
|
|
7
9
|
import {
|
|
8
10
|
__export
|
|
9
11
|
} from "../chunk-MLKGABMK.js";
|
|
10
12
|
|
|
11
|
-
// src/source/path.ts
|
|
12
|
-
function parseFilePath(path) {
|
|
13
|
-
const segments = splitPath(slash(path));
|
|
14
|
-
const dirname = segments.slice(0, -1).join("/");
|
|
15
|
-
const base = segments.at(-1) ?? "";
|
|
16
|
-
const dotIdx = base.lastIndexOf(".");
|
|
17
|
-
const nameWithLocale = dotIdx !== -1 ? base.slice(0, dotIdx) : base;
|
|
18
|
-
const flattenedPath = [dirname, nameWithLocale].filter((p) => p.length > 0).join("/");
|
|
19
|
-
const [name, locale] = getLocale(nameWithLocale);
|
|
20
|
-
return {
|
|
21
|
-
dirname,
|
|
22
|
-
name,
|
|
23
|
-
flattenedPath,
|
|
24
|
-
locale,
|
|
25
|
-
path: segments.join("/")
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function parseFolderPath(path) {
|
|
29
|
-
const segments = splitPath(slash(path));
|
|
30
|
-
const base = segments.at(-1) ?? "";
|
|
31
|
-
const [name, locale] = getLocale(base);
|
|
32
|
-
const flattenedPath = segments.join("/");
|
|
33
|
-
return {
|
|
34
|
-
dirname: segments.slice(0, -1).join("/"),
|
|
35
|
-
name,
|
|
36
|
-
flattenedPath,
|
|
37
|
-
locale,
|
|
38
|
-
path: flattenedPath
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function getLocale(name) {
|
|
42
|
-
const sep = name.lastIndexOf(".");
|
|
43
|
-
if (sep === -1) return [name];
|
|
44
|
-
const locale = name.slice(sep + 1);
|
|
45
|
-
if (/\d+/.exec(locale)) return [name];
|
|
46
|
-
return [name.slice(0, sep), locale];
|
|
47
|
-
}
|
|
48
|
-
function normalizePath(path) {
|
|
49
|
-
const segments = splitPath(slash(path));
|
|
50
|
-
if (segments[0] === "." || segments[0] === "..")
|
|
51
|
-
throw new Error("It must not start with './' or '../'");
|
|
52
|
-
return segments.join("/");
|
|
53
|
-
}
|
|
54
|
-
function splitPath(path) {
|
|
55
|
-
return path.split("/").filter((p) => p.length > 0);
|
|
56
|
-
}
|
|
57
|
-
function resolvePath(from, join) {
|
|
58
|
-
const v1 = splitPath(from), v2 = splitPath(join);
|
|
59
|
-
while (v2.length > 0) {
|
|
60
|
-
switch (v2[0]) {
|
|
61
|
-
case "..":
|
|
62
|
-
v1.pop();
|
|
63
|
-
break;
|
|
64
|
-
case ".":
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
v1.push(v2[0]);
|
|
68
|
-
}
|
|
69
|
-
v2.shift();
|
|
70
|
-
}
|
|
71
|
-
return v1.join("/");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
13
|
// src/source/page-tree-builder.ts
|
|
75
14
|
var group = /^\((?<name>.+)\)$/;
|
|
76
15
|
var link = /^(?:\[(?<icon>[^\]]+)])?\[(?<name>[^\]]+)]\((?<url>[^)]+)\)$/;
|
|
@@ -249,6 +188,50 @@ function pathToName(name, resolveGroup = false) {
|
|
|
249
188
|
return result.join("");
|
|
250
189
|
}
|
|
251
190
|
|
|
191
|
+
// src/source/path.ts
|
|
192
|
+
function parseFilePath(path) {
|
|
193
|
+
const segments = splitPath(slash(path));
|
|
194
|
+
const dirname = segments.slice(0, -1).join("/");
|
|
195
|
+
const base = segments.at(-1) ?? "";
|
|
196
|
+
const dotIdx = base.lastIndexOf(".");
|
|
197
|
+
const nameWithLocale = dotIdx !== -1 ? base.slice(0, dotIdx) : base;
|
|
198
|
+
const flattenedPath = [dirname, nameWithLocale].filter((p) => p.length > 0).join("/");
|
|
199
|
+
const [name, locale] = getLocale(nameWithLocale);
|
|
200
|
+
return {
|
|
201
|
+
dirname,
|
|
202
|
+
name,
|
|
203
|
+
flattenedPath,
|
|
204
|
+
locale,
|
|
205
|
+
path: segments.join("/")
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function parseFolderPath(path) {
|
|
209
|
+
const segments = splitPath(slash(path));
|
|
210
|
+
const base = segments.at(-1) ?? "";
|
|
211
|
+
const [name, locale] = getLocale(base);
|
|
212
|
+
const flattenedPath = segments.join("/");
|
|
213
|
+
return {
|
|
214
|
+
dirname: segments.slice(0, -1).join("/"),
|
|
215
|
+
name,
|
|
216
|
+
flattenedPath,
|
|
217
|
+
locale,
|
|
218
|
+
path: flattenedPath
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function getLocale(name) {
|
|
222
|
+
const sep = name.lastIndexOf(".");
|
|
223
|
+
if (sep === -1) return [name];
|
|
224
|
+
const locale = name.slice(sep + 1);
|
|
225
|
+
if (/\d+/.exec(locale)) return [name];
|
|
226
|
+
return [name.slice(0, sep), locale];
|
|
227
|
+
}
|
|
228
|
+
function normalizePath(path) {
|
|
229
|
+
const segments = splitPath(slash(path));
|
|
230
|
+
if (segments[0] === "." || segments[0] === "..")
|
|
231
|
+
throw new Error("It must not start with './' or '../'");
|
|
232
|
+
return segments.join("/");
|
|
233
|
+
}
|
|
234
|
+
|
|
252
235
|
// src/source/file-system.ts
|
|
253
236
|
var file_system_exports = {};
|
|
254
237
|
__export(file_system_exports, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.2.0",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"import": "./dist/search/algolia.js",
|
|
37
37
|
"types": "./dist/search/algolia.d.ts"
|
|
38
38
|
},
|
|
39
|
+
"./search/orama-cloud": {
|
|
40
|
+
"import": "./dist/search/orama-cloud.js",
|
|
41
|
+
"types": "./dist/search/orama-cloud.d.ts"
|
|
42
|
+
},
|
|
39
43
|
"./server": {
|
|
40
44
|
"import": "./dist/server/index.js",
|
|
41
45
|
"types": "./dist/server/index.d.ts"
|
|
@@ -87,6 +91,7 @@
|
|
|
87
91
|
"devDependencies": {
|
|
88
92
|
"@algolia/client-search": "4.24.0",
|
|
89
93
|
"@mdx-js/mdx": "^3.1.0",
|
|
94
|
+
"@oramacloud/client": "^1.3.18",
|
|
90
95
|
"@types/estree-jsx": "^1.0.5",
|
|
91
96
|
"@types/hast": "^3.0.4",
|
|
92
97
|
"@types/mdast": "^4.0.3",
|
|
@@ -102,16 +107,20 @@
|
|
|
102
107
|
"remark-rehype": "^11.1.1",
|
|
103
108
|
"shiki-transformers": "^1.0.0",
|
|
104
109
|
"unified": "^11.0.5",
|
|
105
|
-
"
|
|
106
|
-
"
|
|
110
|
+
"eslint-config-custom": "0.0.0",
|
|
111
|
+
"tsconfig": "0.0.0"
|
|
107
112
|
},
|
|
108
113
|
"peerDependencies": {
|
|
109
114
|
"algoliasearch": "4.24.0",
|
|
115
|
+
"@oramacloud/client": "1.x.x",
|
|
110
116
|
"next": "14.x.x || 15.x.x",
|
|
111
117
|
"react": ">= 18",
|
|
112
118
|
"react-dom": ">= 18"
|
|
113
119
|
},
|
|
114
120
|
"peerDependenciesMeta": {
|
|
121
|
+
"@oramacloud/client": {
|
|
122
|
+
"optional": true
|
|
123
|
+
},
|
|
115
124
|
"algoliasearch": {
|
|
116
125
|
"optional": true
|
|
117
126
|
},
|
package/dist/chunk-UWEEHUJV.js
DELETED