fumadocs-core 14.7.3 → 14.7.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-2V6SCS43.js → chunk-DELA6Z2I.js} +2 -2
- package/dist/{chunk-BO6MEAPT.js → chunk-GIPLMX5F.js} +1 -1
- package/dist/i18n/index.js +14 -9
- package/dist/mdx-plugins/index.js +5 -5
- package/dist/{orama-cloud-QNHGN6SO.js → orama-cloud-HAZVD2ZO.js} +1 -1
- package/dist/search/client.js +2 -2
- package/dist/search/server.js +2 -2
- package/dist/source/index.d.ts +1 -0
- package/dist/source/index.js +22 -9
- package/dist/{static-7O35FMI3.js → static-KPGOHAZ2.js} +2 -2
- package/package.json +8 -8
package/dist/i18n/index.js
CHANGED
|
@@ -7,7 +7,9 @@ import { NextResponse } from "next/server";
|
|
|
7
7
|
var COOKIE = "FD_LOCALE";
|
|
8
8
|
function getLocale(request, locales, defaultLanguage) {
|
|
9
9
|
const negotiatorHeaders = {};
|
|
10
|
-
request.headers.forEach((value, key) =>
|
|
10
|
+
request.headers.forEach((value, key) => {
|
|
11
|
+
negotiatorHeaders[key] = value;
|
|
12
|
+
});
|
|
11
13
|
const languages = new Negotiator({ headers: negotiatorHeaders }).languages(
|
|
12
14
|
locales
|
|
13
15
|
);
|
|
@@ -35,30 +37,33 @@ function createI18nMiddleware({
|
|
|
35
37
|
);
|
|
36
38
|
}
|
|
37
39
|
return (request) => {
|
|
38
|
-
const
|
|
40
|
+
const inputPath = `${request.nextUrl.pathname}${request.nextUrl.search}`;
|
|
39
41
|
const pathLocale = languages.find(
|
|
40
|
-
(locale) =>
|
|
42
|
+
(locale) => inputPath.startsWith(`/${locale}/`) || inputPath === `/${locale}`
|
|
41
43
|
);
|
|
42
44
|
if (!pathLocale) {
|
|
43
45
|
if (hideLocale === "default-locale") {
|
|
44
|
-
return NextResponse.rewrite(
|
|
46
|
+
return NextResponse.rewrite(
|
|
47
|
+
getUrl(request, inputPath, defaultLanguage)
|
|
48
|
+
);
|
|
45
49
|
}
|
|
46
50
|
const preferred = getLocale(request, languages, defaultLanguage);
|
|
47
51
|
if (hideLocale === "always") {
|
|
48
52
|
const locale = request.cookies.get(COOKIE)?.value ?? preferred;
|
|
49
|
-
return NextResponse.rewrite(getUrl(request,
|
|
53
|
+
return NextResponse.rewrite(getUrl(request, inputPath, locale));
|
|
50
54
|
}
|
|
51
|
-
return NextResponse.redirect(getUrl(request,
|
|
55
|
+
return NextResponse.redirect(getUrl(request, inputPath, preferred));
|
|
52
56
|
}
|
|
53
57
|
if (hideLocale === "always") {
|
|
54
|
-
const path =
|
|
58
|
+
const path = inputPath.slice(`/${pathLocale}`.length);
|
|
55
59
|
const res = NextResponse.redirect(getUrl(request, path));
|
|
56
60
|
res.cookies.set(COOKIE, pathLocale);
|
|
57
61
|
return res;
|
|
58
62
|
}
|
|
59
63
|
if (hideLocale === "default-locale" && pathLocale === defaultLanguage) {
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
return NextResponse.redirect(
|
|
65
|
+
getUrl(request, inputPath.slice(`/${pathLocale}`.length))
|
|
66
|
+
);
|
|
62
67
|
}
|
|
63
68
|
return NextResponse.next();
|
|
64
69
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolvePath,
|
|
3
|
-
slash
|
|
4
|
-
} from "../chunk-SHGL6VBO.js";
|
|
5
1
|
import {
|
|
6
2
|
flattenNode,
|
|
7
3
|
remarkHeading
|
|
8
4
|
} from "../chunk-4MNUWZIW.js";
|
|
5
|
+
import {
|
|
6
|
+
resolvePath,
|
|
7
|
+
slash
|
|
8
|
+
} from "../chunk-SHGL6VBO.js";
|
|
9
9
|
import {
|
|
10
10
|
createStyleTransformer,
|
|
11
11
|
defaultThemes
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
// src/mdx-plugins/rehype-code.ts
|
|
21
21
|
import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
|
|
22
22
|
|
|
23
|
-
// ../../node_modules/.pnpm/shiki-transformers@1.0.1_shiki@1.
|
|
23
|
+
// ../../node_modules/.pnpm/shiki-transformers@1.0.1_shiki@1.27.2/node_modules/shiki-transformers/dist/index.js
|
|
24
24
|
var matchers = [
|
|
25
25
|
[/^(<!--)(.+)(-->)$/, false],
|
|
26
26
|
[/^(\/\*)(.+)(\*\/)$/, false],
|
package/dist/search/client.js
CHANGED
|
@@ -64,10 +64,10 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
|
|
|
64
64
|
return searchDocs(index, debouncedValue, tag, rest);
|
|
65
65
|
}
|
|
66
66
|
if (client.type === "orama-cloud") {
|
|
67
|
-
const { searchDocs } = await import("../orama-cloud-
|
|
67
|
+
const { searchDocs } = await import("../orama-cloud-HAZVD2ZO.js");
|
|
68
68
|
return searchDocs(debouncedValue, tag, client);
|
|
69
69
|
}
|
|
70
|
-
const { createStaticClient } = await import("../static-
|
|
70
|
+
const { createStaticClient } = await import("../static-KPGOHAZ2.js");
|
|
71
71
|
if (!staticClient) staticClient = createStaticClient(client);
|
|
72
72
|
return staticClient.search(debouncedValue, locale, tag);
|
|
73
73
|
}
|
package/dist/search/server.js
CHANGED
package/dist/source/index.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ interface LanguageEntry<Data = PageData> {
|
|
|
102
102
|
}
|
|
103
103
|
interface LoaderOutput<Config extends LoaderConfig> {
|
|
104
104
|
pageTree: Config['i18n'] extends true ? Record<string, Root> : Root;
|
|
105
|
+
getPageTree(locale?: string): Root;
|
|
105
106
|
_i18n?: I18nConfig;
|
|
106
107
|
/**
|
|
107
108
|
* Get list of pages from language, empty if language hasn't specified
|
package/dist/source/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
removeUndefined
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-DELA6Z2I.js";
|
|
4
4
|
import {
|
|
5
5
|
resolvePath,
|
|
6
6
|
slash,
|
|
@@ -17,13 +17,16 @@ var separator = /^---(?<name>.*?)---$/;
|
|
|
17
17
|
var rest = "...";
|
|
18
18
|
var extractPrefix = "...";
|
|
19
19
|
var excludePrefix = "!";
|
|
20
|
+
function isPageFile(node) {
|
|
21
|
+
return "data" in node && node.format === "page";
|
|
22
|
+
}
|
|
20
23
|
function buildAll(nodes, ctx, skipIndex) {
|
|
21
24
|
const output = [];
|
|
22
25
|
const folders = [];
|
|
23
26
|
for (const node of [...nodes].sort(
|
|
24
27
|
(a, b) => a.file.name.localeCompare(b.file.name)
|
|
25
28
|
)) {
|
|
26
|
-
if (
|
|
29
|
+
if (isPageFile(node) && !node.file.locale) {
|
|
27
30
|
const treeNode = buildFileNode(node, ctx);
|
|
28
31
|
if (node.file.name === "index") {
|
|
29
32
|
if (!skipIndex) output.unshift(treeNode);
|
|
@@ -32,7 +35,11 @@ function buildAll(nodes, ctx, skipIndex) {
|
|
|
32
35
|
output.push(treeNode);
|
|
33
36
|
}
|
|
34
37
|
if ("children" in node) {
|
|
35
|
-
|
|
38
|
+
if (node.children.length === 1 && node.children[0].file.name === "index" && isPageFile(node.children[0])) {
|
|
39
|
+
output.push(buildFileNode(node.children[0], ctx));
|
|
40
|
+
} else {
|
|
41
|
+
folders.push(buildFolderNode(node, false, ctx));
|
|
42
|
+
}
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
output.push(...folders);
|
|
@@ -40,17 +47,17 @@ function buildAll(nodes, ctx, skipIndex) {
|
|
|
40
47
|
}
|
|
41
48
|
function resolveFolderItem(folder, item, ctx, addedNodePaths) {
|
|
42
49
|
if (item === rest) return "...";
|
|
43
|
-
|
|
44
|
-
if (
|
|
50
|
+
let match = separator.exec(item);
|
|
51
|
+
if (match?.groups) {
|
|
45
52
|
const node = {
|
|
46
53
|
type: "separator",
|
|
47
|
-
name:
|
|
54
|
+
name: match.groups.name
|
|
48
55
|
};
|
|
49
56
|
return [ctx.options.attachSeparator?.(node) ?? node];
|
|
50
57
|
}
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
const { icon, url, name } =
|
|
58
|
+
match = link.exec(item);
|
|
59
|
+
if (match?.groups) {
|
|
60
|
+
const { icon, url, name } = match.groups;
|
|
54
61
|
const isRelative = url.startsWith("/") || url.startsWith("#") || url.startsWith(".");
|
|
55
62
|
const node = {
|
|
56
63
|
type: "page",
|
|
@@ -426,6 +433,12 @@ function createOutput(options) {
|
|
|
426
433
|
if (!node.$ref?.metaFile) return;
|
|
427
434
|
return walker.pathToMeta.get(node.$ref.metaFile);
|
|
428
435
|
},
|
|
436
|
+
getPageTree(locale) {
|
|
437
|
+
if (options.i18n) {
|
|
438
|
+
return pageTree[locale ?? options.i18n.defaultLanguage];
|
|
439
|
+
}
|
|
440
|
+
return pageTree;
|
|
441
|
+
},
|
|
429
442
|
getNodePage(node) {
|
|
430
443
|
if (!node.$ref?.file) return;
|
|
431
444
|
return walker.pathToPage.get(node.$ref.file);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "14.7.
|
|
3
|
+
"version": "14.7.5",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@formatjs/intl-localematcher": "^0.5.10",
|
|
81
81
|
"@orama/orama": "^2.1.1",
|
|
82
|
-
"@shikijs/rehype": "^1.
|
|
82
|
+
"@shikijs/rehype": "^1.27.2",
|
|
83
83
|
"github-slugger": "^2.0.0",
|
|
84
84
|
"hast-util-to-estree": "^3.1.1",
|
|
85
85
|
"hast-util-to-jsx-runtime": "^2.3.2",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"remark": "^15.0.0",
|
|
90
90
|
"remark-gfm": "^4.0.0",
|
|
91
91
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
92
|
-
"shiki": "^1.
|
|
92
|
+
"shiki": "^1.27.2",
|
|
93
93
|
"unist-util-visit": "^5.0.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
@@ -101,13 +101,13 @@
|
|
|
101
101
|
"@types/hast": "^3.0.4",
|
|
102
102
|
"@types/mdast": "^4.0.3",
|
|
103
103
|
"@types/negotiator": "^0.6.3",
|
|
104
|
-
"@types/node": "22.10.
|
|
105
|
-
"@types/react": "^19.0.
|
|
106
|
-
"@types/react-dom": "^19.0.
|
|
104
|
+
"@types/node": "22.10.7",
|
|
105
|
+
"@types/react": "^19.0.7",
|
|
106
|
+
"@types/react-dom": "^19.0.3",
|
|
107
107
|
"algoliasearch": "4.24.0",
|
|
108
|
-
"mdast-util-mdx-jsx": "^3.
|
|
108
|
+
"mdast-util-mdx-jsx": "^3.2.0",
|
|
109
109
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
110
|
-
"next": "^15.1.
|
|
110
|
+
"next": "^15.1.5",
|
|
111
111
|
"remark-mdx": "^3.1.0",
|
|
112
112
|
"remark-rehype": "^11.1.1",
|
|
113
113
|
"shiki-transformers": "^1.0.1",
|