fumadocs-core 16.2.3 → 16.2.5
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-GINBKBVQ.js +12 -0
- package/dist/{chunk-SLIKY7GW.js → chunk-JUF4WZ6G.js} +11 -5
- package/dist/{chunk-HNZEUF6C.js → chunk-MA6O2UUE.js} +1 -1
- package/dist/{chunk-A4G5V4FQ.js → chunk-VLSDGCJE.js} +1 -1
- package/dist/{chunk-JOXPHQ2R.js → chunk-W6WTLKRA.js} +1 -1
- package/dist/content/mdx/preset-bundler.d.ts +31 -0
- package/dist/content/mdx/preset-bundler.js +72 -0
- package/dist/content/mdx/preset-runtime.d.ts +31 -0
- package/dist/content/mdx/preset-runtime.js +71 -0
- package/dist/content/toc.js +2 -2
- package/dist/i18n/middleware.d.ts +27 -5
- package/dist/i18n/middleware.js +44 -31
- package/dist/{loader-qkSHi822.d.ts → loader-BvlPPJX0.d.ts} +19 -7
- package/dist/mdx-plugins/index.d.ts +1 -1
- package/dist/mdx-plugins/index.js +6 -4
- package/dist/mdx-plugins/remark-admonition.js +2 -2
- package/dist/mdx-plugins/remark-heading.js +2 -2
- package/dist/mdx-plugins/remark-structure.d.ts +9 -2
- package/dist/mdx-plugins/remark-structure.js +4 -2
- package/dist/search/client.d.ts +3 -3
- package/dist/search/client.js +9 -8
- package/dist/search/server.d.ts +1 -1
- package/dist/source/index.d.ts +1 -1
- package/dist/source/index.js +35 -22
- package/dist/source/plugins/lucide-icons.d.ts +1 -1
- package/dist/util-bZU2QeJ2.d.ts +6 -0
- package/package.json +12 -12
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/content/mdx/util.ts
|
|
2
|
+
async function resolvePlugins(def, options = []) {
|
|
3
|
+
const list = (await Promise.all(def(Array.isArray(options) ? options : []))).filter((v) => v !== false);
|
|
4
|
+
if (typeof options === "function") {
|
|
5
|
+
return Promise.all(options(list));
|
|
6
|
+
}
|
|
7
|
+
return list;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
resolvePlugins
|
|
12
|
+
};
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
flattenNode,
|
|
3
3
|
toMdxExport
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VLSDGCJE.js";
|
|
5
5
|
|
|
6
6
|
// src/mdx-plugins/remark-structure.ts
|
|
7
7
|
import Slugger from "github-slugger";
|
|
8
8
|
import { remark } from "remark";
|
|
9
9
|
import remarkGfm from "remark-gfm";
|
|
10
10
|
import { visit } from "unist-util-visit";
|
|
11
|
-
|
|
12
|
-
types
|
|
11
|
+
var remarkStructureDefaultOptions = {
|
|
12
|
+
types: [
|
|
13
13
|
"heading",
|
|
14
14
|
"paragraph",
|
|
15
15
|
"blockquote",
|
|
16
16
|
"tableCell",
|
|
17
17
|
"mdxJsxFlowElement"
|
|
18
18
|
],
|
|
19
|
-
allowedMdxAttributes
|
|
19
|
+
allowedMdxAttributes: (node) => {
|
|
20
20
|
if (!node.name) return false;
|
|
21
21
|
return ["TypeTable", "Callout"].includes(node.name);
|
|
22
22
|
},
|
|
23
|
-
exportAs
|
|
23
|
+
exportAs: false
|
|
24
|
+
};
|
|
25
|
+
function remarkStructure({
|
|
26
|
+
types = remarkStructureDefaultOptions.types,
|
|
27
|
+
allowedMdxAttributes = remarkStructureDefaultOptions.allowedMdxAttributes,
|
|
28
|
+
exportAs = remarkStructureDefaultOptions.exportAs
|
|
24
29
|
} = {}) {
|
|
25
30
|
const slugger = new Slugger();
|
|
26
31
|
if (Array.isArray(allowedMdxAttributes)) {
|
|
@@ -106,6 +111,7 @@ function structure(content, remarkPlugins = [], options = {}) {
|
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
export {
|
|
114
|
+
remarkStructureDefaultOptions,
|
|
109
115
|
remarkStructure,
|
|
110
116
|
structure
|
|
111
117
|
};
|
|
@@ -3,7 +3,7 @@ import { valueToEstree } from "estree-util-value-to-estree";
|
|
|
3
3
|
function flattenNode(node) {
|
|
4
4
|
if ("children" in node)
|
|
5
5
|
return node.children.map((child) => flattenNode(child)).join("");
|
|
6
|
-
if ("value" in node) return node.value;
|
|
6
|
+
if ("value" in node && typeof node.value === "string") return node.value;
|
|
7
7
|
return "";
|
|
8
8
|
}
|
|
9
9
|
function toMdxExport(name, value) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
2
|
+
import { RehypeCodeOptions } from '../../mdx-plugins/rehype-code.js';
|
|
3
|
+
import { RemarkImageOptions } from '../../mdx-plugins/remark-image.js';
|
|
4
|
+
import { StructureOptions } from '../../mdx-plugins/remark-structure.js';
|
|
5
|
+
import { RemarkHeadingOptions } from '../../mdx-plugins/remark-heading.js';
|
|
6
|
+
import { RemarkCodeTabOptions } from '../../mdx-plugins/remark-code-tab.js';
|
|
7
|
+
import { RemarkNpmOptions } from '../../mdx-plugins/remark-npm.js';
|
|
8
|
+
import { R as ResolvePlugins } from '../../util-bZU2QeJ2.js';
|
|
9
|
+
import 'hast';
|
|
10
|
+
import '@shikijs/rehype';
|
|
11
|
+
import 'unified';
|
|
12
|
+
import 'shiki';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdast-util-mdx-jsx';
|
|
15
|
+
|
|
16
|
+
type MDXBundlerPresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
|
|
17
|
+
rehypePlugins?: ResolvePlugins;
|
|
18
|
+
remarkPlugins?: ResolvePlugins;
|
|
19
|
+
remarkStructureOptions?: StructureOptions | false;
|
|
20
|
+
remarkHeadingOptions?: RemarkHeadingOptions;
|
|
21
|
+
remarkImageOptions?: RemarkImageOptions | false;
|
|
22
|
+
remarkCodeTabOptions?: RemarkCodeTabOptions | false;
|
|
23
|
+
remarkNpmOptions?: RemarkNpmOptions | false;
|
|
24
|
+
rehypeCodeOptions?: RehypeCodeOptions | false;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* apply MDX processor presets
|
|
28
|
+
*/
|
|
29
|
+
declare function mdxPreset(options?: MDXBundlerPresetOptions): Promise<ProcessorOptions>;
|
|
30
|
+
|
|
31
|
+
export { type MDXBundlerPresetOptions, mdxPreset };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolvePlugins
|
|
3
|
+
} from "../../chunk-GINBKBVQ.js";
|
|
4
|
+
import "../../chunk-U67V476Y.js";
|
|
5
|
+
|
|
6
|
+
// src/content/mdx/preset-bundler.ts
|
|
7
|
+
async function mdxPreset(options = {}) {
|
|
8
|
+
const {
|
|
9
|
+
rehypeCodeOptions,
|
|
10
|
+
remarkImageOptions,
|
|
11
|
+
remarkHeadingOptions,
|
|
12
|
+
remarkStructureOptions,
|
|
13
|
+
remarkCodeTabOptions,
|
|
14
|
+
remarkNpmOptions,
|
|
15
|
+
...mdxOptions
|
|
16
|
+
} = options;
|
|
17
|
+
const remarkPlugins = await resolvePlugins(
|
|
18
|
+
(v) => [
|
|
19
|
+
import("remark-gfm").then((mod) => mod.default),
|
|
20
|
+
import("../../mdx-plugins/remark-heading.js").then((mod) => [
|
|
21
|
+
mod.remarkHeading,
|
|
22
|
+
{
|
|
23
|
+
generateToc: false,
|
|
24
|
+
...remarkHeadingOptions
|
|
25
|
+
}
|
|
26
|
+
]),
|
|
27
|
+
remarkImageOptions !== false && import("../../mdx-plugins/remark-image.js").then((mod) => [
|
|
28
|
+
mod.remarkImage,
|
|
29
|
+
{
|
|
30
|
+
...remarkImageOptions,
|
|
31
|
+
useImport: remarkImageOptions?.useImport ?? true
|
|
32
|
+
}
|
|
33
|
+
]),
|
|
34
|
+
remarkCodeTabOptions !== false && import("../../mdx-plugins/remark-code-tab.js").then((mod) => [
|
|
35
|
+
mod.remarkCodeTab,
|
|
36
|
+
remarkCodeTabOptions
|
|
37
|
+
]),
|
|
38
|
+
remarkNpmOptions !== false && import("../../mdx-plugins/remark-npm.js").then((mod) => [
|
|
39
|
+
mod.remarkNpm,
|
|
40
|
+
remarkNpmOptions
|
|
41
|
+
]),
|
|
42
|
+
...v,
|
|
43
|
+
remarkStructureOptions !== false && import("../../mdx-plugins/remark-structure.js").then((mod) => [
|
|
44
|
+
mod.remarkStructure,
|
|
45
|
+
{
|
|
46
|
+
exportAs: "structuredData",
|
|
47
|
+
...remarkStructureOptions
|
|
48
|
+
}
|
|
49
|
+
])
|
|
50
|
+
],
|
|
51
|
+
mdxOptions.remarkPlugins
|
|
52
|
+
);
|
|
53
|
+
const rehypePlugins = await resolvePlugins(
|
|
54
|
+
(v) => [
|
|
55
|
+
rehypeCodeOptions !== false && import("../../mdx-plugins/rehype-code.js").then((mod) => [
|
|
56
|
+
mod.rehypeCode,
|
|
57
|
+
rehypeCodeOptions
|
|
58
|
+
]),
|
|
59
|
+
...v,
|
|
60
|
+
import("../../mdx-plugins/rehype-toc.js").then((mod) => mod.rehypeToc)
|
|
61
|
+
],
|
|
62
|
+
mdxOptions.rehypePlugins
|
|
63
|
+
);
|
|
64
|
+
return {
|
|
65
|
+
...mdxOptions,
|
|
66
|
+
remarkPlugins,
|
|
67
|
+
rehypePlugins
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
mdxPreset
|
|
72
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ProcessorOptions } from '@mdx-js/mdx';
|
|
2
|
+
import { RehypeCodeOptions } from '../../mdx-plugins/rehype-code.js';
|
|
3
|
+
import { RemarkImageOptions } from '../../mdx-plugins/remark-image.js';
|
|
4
|
+
import { StructureOptions } from '../../mdx-plugins/remark-structure.js';
|
|
5
|
+
import { RemarkHeadingOptions } from '../../mdx-plugins/remark-heading.js';
|
|
6
|
+
import { RemarkCodeTabOptions } from '../../mdx-plugins/remark-code-tab.js';
|
|
7
|
+
import { RemarkNpmOptions } from '../../mdx-plugins/remark-npm.js';
|
|
8
|
+
import { R as ResolvePlugins } from '../../util-bZU2QeJ2.js';
|
|
9
|
+
import 'hast';
|
|
10
|
+
import '@shikijs/rehype';
|
|
11
|
+
import 'unified';
|
|
12
|
+
import 'shiki';
|
|
13
|
+
import 'mdast';
|
|
14
|
+
import 'mdast-util-mdx-jsx';
|
|
15
|
+
|
|
16
|
+
type MDXRuntimePresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
|
|
17
|
+
rehypePlugins?: ResolvePlugins;
|
|
18
|
+
remarkPlugins?: ResolvePlugins;
|
|
19
|
+
remarkStructureOptions?: StructureOptions | false;
|
|
20
|
+
remarkHeadingOptions?: RemarkHeadingOptions;
|
|
21
|
+
remarkImageOptions?: RemarkImageOptions | false;
|
|
22
|
+
remarkCodeTabOptions?: RemarkCodeTabOptions | false;
|
|
23
|
+
remarkNpmOptions?: RemarkNpmOptions | false;
|
|
24
|
+
rehypeCodeOptions?: RehypeCodeOptions | false;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* apply MDX processor presets
|
|
28
|
+
*/
|
|
29
|
+
declare function mdxPreset(options?: MDXRuntimePresetOptions): Promise<ProcessorOptions>;
|
|
30
|
+
|
|
31
|
+
export { type MDXRuntimePresetOptions, mdxPreset };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolvePlugins
|
|
3
|
+
} from "../../chunk-GINBKBVQ.js";
|
|
4
|
+
import "../../chunk-U67V476Y.js";
|
|
5
|
+
|
|
6
|
+
// src/content/mdx/preset-runtime.ts
|
|
7
|
+
async function mdxPreset(options = {}) {
|
|
8
|
+
const {
|
|
9
|
+
rehypeCodeOptions,
|
|
10
|
+
remarkImageOptions,
|
|
11
|
+
remarkHeadingOptions,
|
|
12
|
+
remarkStructureOptions,
|
|
13
|
+
remarkCodeTabOptions,
|
|
14
|
+
remarkNpmOptions,
|
|
15
|
+
outputFormat = "function-body",
|
|
16
|
+
...mdxOptions
|
|
17
|
+
} = options;
|
|
18
|
+
const remarkPlugins = await resolvePlugins(
|
|
19
|
+
(v) => [
|
|
20
|
+
import("remark-gfm").then((mod) => mod.default),
|
|
21
|
+
import("../../mdx-plugins/remark-heading.js").then((mod) => [
|
|
22
|
+
mod.remarkHeading,
|
|
23
|
+
{
|
|
24
|
+
generateToc: false,
|
|
25
|
+
...remarkHeadingOptions
|
|
26
|
+
}
|
|
27
|
+
]),
|
|
28
|
+
remarkImageOptions !== false && import("../../mdx-plugins/remark-image.js").then((mod) => [
|
|
29
|
+
mod.remarkImage,
|
|
30
|
+
remarkImageOptions
|
|
31
|
+
]),
|
|
32
|
+
remarkCodeTabOptions !== false && import("../../mdx-plugins/remark-code-tab.js").then((mod) => [
|
|
33
|
+
mod.remarkCodeTab,
|
|
34
|
+
remarkCodeTabOptions
|
|
35
|
+
]),
|
|
36
|
+
remarkNpmOptions !== false && import("../../mdx-plugins/remark-npm.js").then((mod) => [
|
|
37
|
+
mod.remarkNpm,
|
|
38
|
+
remarkNpmOptions
|
|
39
|
+
]),
|
|
40
|
+
...v,
|
|
41
|
+
remarkStructureOptions !== false && import("../../mdx-plugins/remark-structure.js").then((mod) => [
|
|
42
|
+
mod.remarkStructure,
|
|
43
|
+
{
|
|
44
|
+
exportAs: "structuredData",
|
|
45
|
+
...remarkStructureOptions
|
|
46
|
+
}
|
|
47
|
+
])
|
|
48
|
+
],
|
|
49
|
+
mdxOptions.remarkPlugins
|
|
50
|
+
);
|
|
51
|
+
const rehypePlugins = await resolvePlugins(
|
|
52
|
+
(v) => [
|
|
53
|
+
rehypeCodeOptions !== false && import("../../mdx-plugins/rehype-code.js").then((mod) => [
|
|
54
|
+
mod.rehypeCode,
|
|
55
|
+
rehypeCodeOptions
|
|
56
|
+
]),
|
|
57
|
+
...v,
|
|
58
|
+
import("../../mdx-plugins/rehype-toc.js").then((mod) => mod.rehypeToc)
|
|
59
|
+
],
|
|
60
|
+
mdxOptions.rehypePlugins
|
|
61
|
+
);
|
|
62
|
+
return {
|
|
63
|
+
...mdxOptions,
|
|
64
|
+
outputFormat,
|
|
65
|
+
remarkPlugins,
|
|
66
|
+
rehypePlugins
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
mdxPreset
|
|
71
|
+
};
|
package/dist/content/toc.js
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
import { NextProxy } from 'next/
|
|
1
|
+
import { NextProxy } from 'next/server';
|
|
2
2
|
import { I18nConfig } from './index.js';
|
|
3
|
+
import { NextURL } from 'next/dist/server/web/next-url';
|
|
3
4
|
|
|
4
5
|
interface MiddlewareOptions extends I18nConfig {
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* Either:
|
|
8
|
+
* - A formatter object
|
|
9
|
+
* - A function that adds the locale prefix to pathname
|
|
7
10
|
*/
|
|
8
|
-
format?: (locale: string,
|
|
11
|
+
format?: URLFormatter | ((locale: string, pathname: string) => string);
|
|
12
|
+
/**
|
|
13
|
+
* the cookie to store locale code when `hideLocale` is set to `always`.
|
|
14
|
+
*/
|
|
15
|
+
cookieName?: string;
|
|
16
|
+
}
|
|
17
|
+
interface URLFormatter {
|
|
18
|
+
/**
|
|
19
|
+
* get locale code from request URL
|
|
20
|
+
*/
|
|
21
|
+
get: (url: NextURL) => string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* add locale code to request URL (which is missing the locale).
|
|
24
|
+
*/
|
|
25
|
+
add: (url: NextURL, locale: string) => URL;
|
|
26
|
+
/**
|
|
27
|
+
* remove locale code from request URL
|
|
28
|
+
*/
|
|
29
|
+
remove: (url: NextURL) => URL;
|
|
9
30
|
}
|
|
10
|
-
declare
|
|
31
|
+
declare const DefaultFormatter: URLFormatter;
|
|
32
|
+
declare function createI18nMiddleware({ languages, defaultLanguage, format, cookieName, hideLocale, }: MiddlewareOptions): NextProxy;
|
|
11
33
|
|
|
12
|
-
export { createI18nMiddleware };
|
|
34
|
+
export { DefaultFormatter, type URLFormatter, createI18nMiddleware };
|
package/dist/i18n/middleware.js
CHANGED
|
@@ -6,58 +6,71 @@ import "../chunk-U67V476Y.js";
|
|
|
6
6
|
// src/i18n/middleware.ts
|
|
7
7
|
import { match as matchLocale } from "@formatjs/intl-localematcher";
|
|
8
8
|
import { NextResponse } from "next/server";
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
var DefaultFormatter = {
|
|
10
|
+
get(url) {
|
|
11
|
+
const segs = url.pathname.split("/");
|
|
12
|
+
if (segs.length > 1 && segs[1]) return segs[1];
|
|
13
|
+
},
|
|
14
|
+
add(url, locale) {
|
|
15
|
+
const next = new URL(url);
|
|
16
|
+
next.pathname = `${url.basePath}/${locale}/${url.pathname}`.replaceAll(
|
|
17
|
+
/\/+/g,
|
|
18
|
+
"/"
|
|
19
|
+
);
|
|
20
|
+
return next;
|
|
21
|
+
},
|
|
22
|
+
remove(url) {
|
|
23
|
+
const next = new URL(url);
|
|
24
|
+
const pathname = url.pathname.split("/").slice(2).join("/");
|
|
25
|
+
next.pathname = `${url.basePath}/${pathname}`.replaceAll(/\/+/g, "/");
|
|
26
|
+
return next;
|
|
27
|
+
}
|
|
16
28
|
};
|
|
17
29
|
function createI18nMiddleware({
|
|
18
30
|
languages,
|
|
19
31
|
defaultLanguage,
|
|
20
|
-
format =
|
|
32
|
+
format = DefaultFormatter,
|
|
33
|
+
cookieName = "FD_LOCALE",
|
|
21
34
|
hideLocale = "never"
|
|
22
35
|
}) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
let formatter;
|
|
37
|
+
if (typeof format === "function") {
|
|
38
|
+
formatter = {
|
|
39
|
+
...DefaultFormatter,
|
|
40
|
+
add(url, locale) {
|
|
41
|
+
const next = new URL(url);
|
|
42
|
+
next.pathname = format(locale, url.pathname);
|
|
43
|
+
return next;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
formatter = format;
|
|
27
48
|
}
|
|
28
49
|
return (request) => {
|
|
29
50
|
const url = request.nextUrl;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
51
|
+
let pathLocale = formatter.get(url);
|
|
52
|
+
if (pathLocale && !languages.includes(pathLocale)) pathLocale = void 0;
|
|
33
53
|
if (!pathLocale) {
|
|
34
54
|
if (hideLocale === "default-locale") {
|
|
35
|
-
return NextResponse.rewrite(
|
|
55
|
+
return NextResponse.rewrite(formatter.add(url, defaultLanguage));
|
|
36
56
|
}
|
|
37
|
-
const
|
|
57
|
+
const finalLanguages = getNegotiator(request).languages(languages);
|
|
58
|
+
const preferred = matchLocale(finalLanguages, languages, defaultLanguage);
|
|
38
59
|
if (hideLocale === "always") {
|
|
39
|
-
const locale = request.cookies.get(
|
|
40
|
-
return NextResponse.rewrite(
|
|
60
|
+
const locale = request.cookies.get(cookieName)?.value ?? preferred;
|
|
61
|
+
return NextResponse.rewrite(formatter.add(url, locale));
|
|
41
62
|
}
|
|
42
|
-
return NextResponse.redirect(
|
|
63
|
+
return NextResponse.redirect(formatter.add(url, preferred));
|
|
43
64
|
}
|
|
44
65
|
if (hideLocale === "always" || hideLocale === "default-locale" && pathLocale === defaultLanguage) {
|
|
45
|
-
const res = NextResponse.redirect(
|
|
46
|
-
|
|
47
|
-
forceSlashPrefix(url.pathname.slice(`/${pathLocale}`.length)),
|
|
48
|
-
request.url
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
res.cookies.set(COOKIE, pathLocale);
|
|
66
|
+
const res = NextResponse.redirect(formatter.remove(url));
|
|
67
|
+
res.cookies.set(cookieName, pathLocale);
|
|
52
68
|
return res;
|
|
53
69
|
}
|
|
54
70
|
return NextResponse.next();
|
|
55
71
|
};
|
|
56
72
|
}
|
|
57
|
-
function forceSlashPrefix(v) {
|
|
58
|
-
if (v.startsWith("/")) return v;
|
|
59
|
-
return "/" + v;
|
|
60
|
-
}
|
|
61
73
|
export {
|
|
74
|
+
DefaultFormatter,
|
|
62
75
|
createI18nMiddleware
|
|
63
76
|
};
|
|
@@ -59,18 +59,30 @@ type _ConfigUnion_<T extends Record<string, Source>> = {
|
|
|
59
59
|
} : never;
|
|
60
60
|
}[keyof T];
|
|
61
61
|
declare function multiple<T extends Record<string, Source>>(sources: T): Source<_ConfigUnion_<T>>;
|
|
62
|
+
declare function source<Page extends PageData, Meta extends MetaData>(config: {
|
|
63
|
+
pages: VirtualPage<Page>[];
|
|
64
|
+
metas: VirtualMeta<Meta>[];
|
|
65
|
+
}): Source<{
|
|
66
|
+
pageData: Page;
|
|
67
|
+
metaData: Meta;
|
|
68
|
+
}>;
|
|
62
69
|
/**
|
|
63
|
-
*
|
|
70
|
+
* update a source object in-place.
|
|
64
71
|
*/
|
|
65
|
-
declare function
|
|
66
|
-
|
|
67
|
-
pageData:
|
|
72
|
+
declare function update<Config extends SourceConfig>(source: Source<Config>): {
|
|
73
|
+
files<Page extends PageData, Meta extends MetaData>(fn: (files: VirtualFile<Config>[]) => (VirtualPage<Page> | VirtualMeta<Meta>)[]): typeof update<{
|
|
74
|
+
pageData: Page;
|
|
75
|
+
metaData: Meta;
|
|
76
|
+
}>;
|
|
77
|
+
page<V extends PageData>(fn: (page: VirtualPage<Config["pageData"]>) => VirtualPage<V>): typeof update<{
|
|
78
|
+
pageData: V;
|
|
68
79
|
metaData: Config["metaData"];
|
|
69
80
|
}>;
|
|
70
|
-
meta
|
|
81
|
+
meta<V extends MetaData>(fn: (meta: VirtualMeta<Config["metaData"]>) => VirtualMeta<V>): typeof update<{
|
|
71
82
|
pageData: Config["pageData"];
|
|
72
|
-
metaData:
|
|
83
|
+
metaData: V;
|
|
73
84
|
}>;
|
|
85
|
+
build(): Source<Config>;
|
|
74
86
|
};
|
|
75
87
|
|
|
76
88
|
/**
|
|
@@ -306,4 +318,4 @@ declare function loader<Config extends SourceConfig, I18n extends I18nConfig | u
|
|
|
306
318
|
type InferPageType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Page<Config['source']['pageData']> : never;
|
|
307
319
|
type InferMetaType<Utils extends LoaderOutput<any>> = Utils extends LoaderOutput<infer Config> ? Meta<Config['source']['metaData']> : never;
|
|
308
320
|
|
|
309
|
-
export { type ContentStorage as C, FileSystem as F, type InferPageType as I, type LoaderPlugin as L, type MetaData as M, type PageData as P, type ResolvedLoaderConfig as R, type Source as S, type VirtualFile as V, type _ConfigUnion_ as _, type SourceConfig as a,
|
|
321
|
+
export { type ContentStorage as C, FileSystem as F, type InferPageType as I, type LoaderPlugin as L, type MetaData as M, type PageData as P, type ResolvedLoaderConfig as R, type Source as S, type VirtualFile as V, type _ConfigUnion_ as _, type SourceConfig as a, type LoaderConfig as b, type LoaderOptions as c, type Page as d, type Meta as e, type LoaderOutput as f, createGetUrl as g, type InferMetaType as h, type PageTreeBuilderContext as i, type PageTreeTransformer as j, type PageTreeOptions as k, loader as l, multiple as m, type PageTreeBuilder as n, createPageTreeBuilder as o, type ContentStorageFile as p, buildContentStorage as q, type LoaderPluginOption as r, source as s, buildPlugins as t, update as u };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Options as RemarkGfmOptions, default as remarkGfm } from 'remark-gfm';
|
|
2
2
|
export { CodeBlockIcon, RehypeCodeOptions, rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab } from './rehype-code.js';
|
|
3
3
|
export { RemarkImageOptions, remarkImage } from './remark-image.js';
|
|
4
|
-
export { StructureOptions, StructuredData, remarkStructure, structure } from './remark-structure.js';
|
|
4
|
+
export { StructureOptions, StructuredData, remarkStructure, remarkStructureDefaultOptions, structure } from './remark-structure.js';
|
|
5
5
|
export { RemarkHeadingOptions, remarkHeading } from './remark-heading.js';
|
|
6
6
|
export { RemarkAdmonitionOptions, remarkAdmonition } from './remark-admonition.js';
|
|
7
7
|
export { RemarkDirectiveAdmonitionOptions, remarkDirectiveAdmonition } from './remark-directive-admonition.js';
|
|
@@ -15,8 +15,9 @@ import {
|
|
|
15
15
|
} from "../chunk-XJ6ZQNEX.js";
|
|
16
16
|
import {
|
|
17
17
|
remarkStructure,
|
|
18
|
+
remarkStructureDefaultOptions,
|
|
18
19
|
structure
|
|
19
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-JUF4WZ6G.js";
|
|
20
21
|
import {
|
|
21
22
|
rehypeCode,
|
|
22
23
|
rehypeCodeDefaultOptions,
|
|
@@ -28,7 +29,7 @@ import {
|
|
|
28
29
|
} from "../chunk-EFVXL2PP.js";
|
|
29
30
|
import {
|
|
30
31
|
remarkAdmonition
|
|
31
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-W6WTLKRA.js";
|
|
32
33
|
import {
|
|
33
34
|
remarkCodeTab
|
|
34
35
|
} from "../chunk-CH7YHH7V.js";
|
|
@@ -45,8 +46,8 @@ import {
|
|
|
45
46
|
import "../chunk-XN2LKXFZ.js";
|
|
46
47
|
import {
|
|
47
48
|
remarkHeading
|
|
48
|
-
} from "../chunk-
|
|
49
|
-
import "../chunk-
|
|
49
|
+
} from "../chunk-MA6O2UUE.js";
|
|
50
|
+
import "../chunk-VLSDGCJE.js";
|
|
50
51
|
import "../chunk-U67V476Y.js";
|
|
51
52
|
export {
|
|
52
53
|
generateCodeBlockTabs,
|
|
@@ -65,6 +66,7 @@ export {
|
|
|
65
66
|
remarkNpm,
|
|
66
67
|
remarkSteps,
|
|
67
68
|
remarkStructure,
|
|
69
|
+
remarkStructureDefaultOptions,
|
|
68
70
|
structure,
|
|
69
71
|
transformerIcon,
|
|
70
72
|
transformerTab
|
|
@@ -52,8 +52,15 @@ declare module 'vfile' {
|
|
|
52
52
|
structuredData: StructuredData;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
declare const remarkStructureDefaultOptions: {
|
|
56
|
+
types: string[];
|
|
57
|
+
allowedMdxAttributes: (node: MdxJsxFlowElement) => boolean;
|
|
58
|
+
exportAs: false;
|
|
59
|
+
};
|
|
55
60
|
/**
|
|
56
|
-
*
|
|
61
|
+
* Extract content into structured data.
|
|
62
|
+
*
|
|
63
|
+
* By default, the output is stored into VFile (`vfile.data.structuredData`), you can specify `exportAs` to export it.
|
|
57
64
|
*/
|
|
58
65
|
declare function remarkStructure({ types, allowedMdxAttributes, exportAs, }?: StructureOptions): Transformer<Root, Root>;
|
|
59
66
|
/**
|
|
@@ -61,4 +68,4 @@ declare function remarkStructure({ types, allowedMdxAttributes, exportAs, }?: St
|
|
|
61
68
|
*/
|
|
62
69
|
declare function structure(content: string, remarkPlugins?: PluggableList, options?: StructureOptions): StructuredData;
|
|
63
70
|
|
|
64
|
-
export { type StructureOptions, type StructuredData, remarkStructure, structure };
|
|
71
|
+
export { type StructureOptions, type StructuredData, remarkStructure, remarkStructureDefaultOptions, structure };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
remarkStructure,
|
|
3
|
+
remarkStructureDefaultOptions,
|
|
3
4
|
structure
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-JUF4WZ6G.js";
|
|
6
|
+
import "../chunk-VLSDGCJE.js";
|
|
6
7
|
import "../chunk-U67V476Y.js";
|
|
7
8
|
export {
|
|
8
9
|
remarkStructure,
|
|
10
|
+
remarkStructureDefaultOptions,
|
|
9
11
|
structure
|
|
10
12
|
};
|
package/dist/search/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DependencyList } from 'react';
|
|
1
2
|
import { AnyOrama } from '@orama/orama';
|
|
2
3
|
import '../mdx-plugins/remark-structure.js';
|
|
3
4
|
import { BaseIndex } from './algolia.js';
|
|
@@ -9,7 +10,6 @@ import 'mdast';
|
|
|
9
10
|
import 'unified';
|
|
10
11
|
import 'mdast-util-mdx-jsx';
|
|
11
12
|
import 'algoliasearch';
|
|
12
|
-
import 'react';
|
|
13
13
|
|
|
14
14
|
interface FetchOptions {
|
|
15
15
|
/**
|
|
@@ -120,7 +120,7 @@ type Client = ({
|
|
|
120
120
|
/**
|
|
121
121
|
* Provide a hook to query different official search clients.
|
|
122
122
|
*
|
|
123
|
-
* Note: it will re-query when its parameters changed, make sure to use `
|
|
123
|
+
* Note: it will re-query when its parameters changed, make sure to use `useMemo()` on `clientOptions` or define `deps` array.
|
|
124
124
|
*/
|
|
125
125
|
declare function useDocsSearch(clientOptions: Client & {
|
|
126
126
|
/**
|
|
@@ -135,6 +135,6 @@ declare function useDocsSearch(clientOptions: Client & {
|
|
|
135
135
|
* @defaultValue false
|
|
136
136
|
*/
|
|
137
137
|
allowEmpty?: boolean;
|
|
138
|
-
}): UseDocsSearch;
|
|
138
|
+
}, deps?: DependencyList): UseDocsSearch;
|
|
139
139
|
|
|
140
140
|
export { type AlgoliaOptions, type Client, type FetchOptions, type OramaCloudOptions, type StaticOptions, useDocsSearch };
|
package/dist/search/client.js
CHANGED
|
@@ -22,20 +22,21 @@ function useDebounce(value, delayMs = 1e3) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// src/search/client.ts
|
|
25
|
-
function
|
|
25
|
+
function isDeepEqual(a, b) {
|
|
26
|
+
if (a === b) return true;
|
|
26
27
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
27
|
-
return b.length
|
|
28
|
+
return b.length === a.length && a.every((v, i) => isDeepEqual(v, b[i]));
|
|
28
29
|
}
|
|
29
30
|
if (typeof a === "object" && a && typeof b === "object" && b) {
|
|
30
31
|
const aKeys = Object.keys(a);
|
|
31
32
|
const bKeys = Object.keys(b);
|
|
32
|
-
return aKeys.length
|
|
33
|
-
(key) =>
|
|
33
|
+
return aKeys.length === bKeys.length && aKeys.every(
|
|
34
|
+
(key) => Object.hasOwn(b, key) && isDeepEqual(a[key], b[key])
|
|
34
35
|
);
|
|
35
36
|
}
|
|
36
|
-
return
|
|
37
|
+
return false;
|
|
37
38
|
}
|
|
38
|
-
function useDocsSearch(clientOptions) {
|
|
39
|
+
function useDocsSearch(clientOptions, deps) {
|
|
39
40
|
const { delayMs = 100, allowEmpty = false, ...client } = clientOptions;
|
|
40
41
|
const [search, setSearch] = useState2("");
|
|
41
42
|
const [results, setResults] = useState2("empty");
|
|
@@ -44,7 +45,7 @@ function useDocsSearch(clientOptions) {
|
|
|
44
45
|
const debouncedValue = useDebounce(search, delayMs);
|
|
45
46
|
const onStart = useRef(void 0);
|
|
46
47
|
useOnChange(
|
|
47
|
-
[
|
|
48
|
+
[deps ?? clientOptions, debouncedValue],
|
|
48
49
|
() => {
|
|
49
50
|
if (onStart.current) {
|
|
50
51
|
onStart.current();
|
|
@@ -89,7 +90,7 @@ function useDocsSearch(clientOptions) {
|
|
|
89
90
|
setIsLoading(false);
|
|
90
91
|
});
|
|
91
92
|
},
|
|
92
|
-
|
|
93
|
+
deps ? void 0 : (a, b) => !isDeepEqual(a, b)
|
|
93
94
|
);
|
|
94
95
|
return { search, setSearch, query: { isLoading, data: results, error } };
|
|
95
96
|
}
|
package/dist/search/server.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { StructuredData } from '../mdx-plugins/remark-structure.js';
|
|
|
3
3
|
import { SortedResult } from './index.js';
|
|
4
4
|
export { HighlightedText, ReactSortedResult, createContentHighlighter } from './index.js';
|
|
5
5
|
import { I18nConfig } from '../i18n/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { f as LoaderOutput, b as LoaderConfig, I as InferPageType } from '../loader-BvlPPJX0.js';
|
|
7
7
|
import 'mdast';
|
|
8
8
|
import 'unified';
|
|
9
9
|
import 'mdast-util-mdx-jsx';
|
package/dist/source/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as ContentStorage,
|
|
1
|
+
export { C as ContentStorage, p as ContentStorageFile, F as FileSystem, h as InferMetaType, I as InferPageType, b as LoaderConfig, c as LoaderOptions, f as LoaderOutput, L as LoaderPlugin, r as LoaderPluginOption, e as Meta, M as MetaData, d as Page, P as PageData, n as PageTreeBuilder, i as PageTreeBuilderContext, k as PageTreeOptions, j as PageTreeTransformer, R as ResolvedLoaderConfig, S as Source, a as SourceConfig, V as VirtualFile, _ as _ConfigUnion_, q as buildContentStorage, t as buildPlugins, g as createGetUrl, o as createPageTreeBuilder, l as loader, m as multiple, s as source, u as update } from '../loader-BvlPPJX0.js';
|
|
2
2
|
import '../definitions-pJ7PybYY.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '../i18n/index.js';
|
package/dist/source/index.js
CHANGED
|
@@ -21,8 +21,8 @@ import "../chunk-U67V476Y.js";
|
|
|
21
21
|
// src/source/source.ts
|
|
22
22
|
function multiple(sources) {
|
|
23
23
|
const out = { files: [] };
|
|
24
|
-
for (const [type,
|
|
25
|
-
for (const file of
|
|
24
|
+
for (const [type, source2] of Object.entries(sources)) {
|
|
25
|
+
for (const file of source2.files) {
|
|
26
26
|
out.files.push({
|
|
27
27
|
...file,
|
|
28
28
|
data: {
|
|
@@ -34,21 +34,33 @@ function multiple(sources) {
|
|
|
34
34
|
}
|
|
35
35
|
return out;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function source(config) {
|
|
38
38
|
return {
|
|
39
|
+
files: [...config.pages, ...config.metas]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function update(source2) {
|
|
43
|
+
return {
|
|
44
|
+
files(fn) {
|
|
45
|
+
source2.files = fn(source2.files);
|
|
46
|
+
return this;
|
|
47
|
+
},
|
|
39
48
|
page(fn) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
for (let i = 0; i < source2.files.length; i++) {
|
|
50
|
+
const file = source2.files[i];
|
|
51
|
+
if (file.type === "page") source2.files[i] = fn(file);
|
|
52
|
+
}
|
|
53
|
+
return this;
|
|
45
54
|
},
|
|
46
55
|
meta(fn) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
for (let i = 0; i < source2.files.length; i++) {
|
|
57
|
+
const file = source2.files[i];
|
|
58
|
+
if (file.type === "meta") source2.files[i] = fn(file);
|
|
59
|
+
}
|
|
60
|
+
return this;
|
|
61
|
+
},
|
|
62
|
+
build() {
|
|
63
|
+
return source2;
|
|
52
64
|
}
|
|
53
65
|
};
|
|
54
66
|
}
|
|
@@ -145,7 +157,7 @@ var parsers = {
|
|
|
145
157
|
};
|
|
146
158
|
function buildContentStorage(loaderConfig, defaultLanguage) {
|
|
147
159
|
const {
|
|
148
|
-
source,
|
|
160
|
+
source: source2,
|
|
149
161
|
plugins = [],
|
|
150
162
|
i18n = {
|
|
151
163
|
defaultLanguage,
|
|
@@ -156,7 +168,7 @@ function buildContentStorage(loaderConfig, defaultLanguage) {
|
|
|
156
168
|
const parser = parsers[i18n.parser ?? "dot"];
|
|
157
169
|
const storages = {};
|
|
158
170
|
const normalized = /* @__PURE__ */ new Map();
|
|
159
|
-
for (const inputFile of
|
|
171
|
+
for (const inputFile of source2.files) {
|
|
160
172
|
let file;
|
|
161
173
|
if (inputFile.type === "page") {
|
|
162
174
|
file = {
|
|
@@ -298,15 +310,15 @@ function createPageTreeBuilder(loaderConfig) {
|
|
|
298
310
|
};
|
|
299
311
|
}
|
|
300
312
|
function createFlattenPathResolver(storage) {
|
|
301
|
-
const
|
|
313
|
+
const map = /* @__PURE__ */ new Map();
|
|
302
314
|
const files = storage.getFiles();
|
|
303
315
|
for (const file of files) {
|
|
304
316
|
const content = storage.read(file);
|
|
305
317
|
const flattenPath = file.substring(0, file.length - extname(file).length);
|
|
306
|
-
|
|
318
|
+
map.set(flattenPath + "." + content.format, file);
|
|
307
319
|
}
|
|
308
320
|
return (name, format) => {
|
|
309
|
-
return
|
|
321
|
+
return map.get(name + "." + format) ?? name;
|
|
310
322
|
};
|
|
311
323
|
}
|
|
312
324
|
function createPageTreeBuilderUtils(ctx) {
|
|
@@ -733,11 +745,11 @@ function loader(...args) {
|
|
|
733
745
|
}
|
|
734
746
|
};
|
|
735
747
|
}
|
|
736
|
-
function resolveConfig(
|
|
748
|
+
function resolveConfig(source2, { slugs, icon, plugins = [], baseUrl, url, ...base }) {
|
|
737
749
|
let config = {
|
|
738
750
|
...base,
|
|
739
751
|
url: url ? (...args) => normalizeUrl(url(...args)) : createGetUrl(baseUrl, base.i18n),
|
|
740
|
-
source,
|
|
752
|
+
source: source2,
|
|
741
753
|
plugins: buildPlugins([
|
|
742
754
|
slugsPlugin(slugs),
|
|
743
755
|
icon && iconPlugin(icon),
|
|
@@ -758,6 +770,7 @@ export {
|
|
|
758
770
|
createGetUrl,
|
|
759
771
|
getSlugs,
|
|
760
772
|
loader,
|
|
761
|
-
|
|
762
|
-
|
|
773
|
+
multiple,
|
|
774
|
+
source,
|
|
775
|
+
update
|
|
763
776
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.5",
|
|
4
4
|
"description": "The React.js library for building a documentation website",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fumadocs",
|
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@formatjs/intl-localematcher": "^0.6.2",
|
|
113
113
|
"@orama/orama": "^3.1.16",
|
|
114
|
-
"@shikijs/rehype": "^3.
|
|
115
|
-
"@shikijs/transformers": "^3.
|
|
114
|
+
"@shikijs/rehype": "^3.20.0",
|
|
115
|
+
"@shikijs/transformers": "^3.20.0",
|
|
116
116
|
"estree-util-value-to-estree": "^3.5.0",
|
|
117
117
|
"github-slugger": "^2.0.0",
|
|
118
118
|
"hast-util-to-estree": "^3.1.3",
|
|
@@ -125,34 +125,34 @@
|
|
|
125
125
|
"remark-gfm": "^4.0.1",
|
|
126
126
|
"remark-rehype": "^11.1.2",
|
|
127
127
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
128
|
-
"shiki": "^3.
|
|
128
|
+
"shiki": "^3.20.0",
|
|
129
129
|
"unist-util-visit": "^5.0.0"
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|
|
132
132
|
"@mdx-js/mdx": "^3.1.1",
|
|
133
|
-
"@mixedbread/sdk": "^0.
|
|
134
|
-
"@orama/core": "^1.2.
|
|
133
|
+
"@mixedbread/sdk": "^0.46.0",
|
|
134
|
+
"@orama/core": "^1.2.14",
|
|
135
135
|
"@tanstack/react-router": "1.136.18",
|
|
136
136
|
"@types/estree-jsx": "^1.0.5",
|
|
137
137
|
"@types/hast": "^3.0.4",
|
|
138
138
|
"@types/mdast": "^4.0.4",
|
|
139
139
|
"@types/negotiator": "^0.6.4",
|
|
140
|
-
"@types/node": "24.10.
|
|
140
|
+
"@types/node": "24.10.2",
|
|
141
141
|
"@types/react": "^19.2.7",
|
|
142
142
|
"@types/react-dom": "^19.2.3",
|
|
143
|
-
"algoliasearch": "5.
|
|
144
|
-
"lucide-react": "^0.
|
|
143
|
+
"algoliasearch": "5.46.0",
|
|
144
|
+
"lucide-react": "^0.561.0",
|
|
145
145
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
146
146
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
147
|
-
"next": "16.0.
|
|
148
|
-
"react-router": "^7.10.
|
|
147
|
+
"next": "16.0.10",
|
|
148
|
+
"react-router": "^7.10.1",
|
|
149
149
|
"remark-directive": "^4.0.0",
|
|
150
150
|
"remark-mdx": "^3.1.1",
|
|
151
151
|
"remove-markdown": "^0.6.2",
|
|
152
152
|
"typescript": "^5.9.3",
|
|
153
153
|
"unified": "^11.0.5",
|
|
154
154
|
"vfile": "^6.0.3",
|
|
155
|
-
"waku": "^0.27.
|
|
155
|
+
"waku": "^0.27.4",
|
|
156
156
|
"zod": "^4.1.13",
|
|
157
157
|
"eslint-config-custom": "0.0.0",
|
|
158
158
|
"tsconfig": "0.0.0"
|