fumadocs-core 15.7.4 → 15.7.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.
@@ -1,3 +1,6 @@
1
+ import {
2
+ normalizeUrl
3
+ } from "./chunk-PFNP6PEB.js";
1
4
  import "./chunk-JSBRDJBE.js";
2
5
 
3
6
  // src/breadcrumb.tsx
@@ -52,31 +55,33 @@ function getBreadcrumbItemsFromPath(tree, path, options) {
52
55
  return items;
53
56
  }
54
57
  function searchPath(nodes, url) {
55
- if (url.endsWith("/")) url = url.slice(0, -1);
56
- let separator;
57
- for (const node of nodes) {
58
- if (node.type === "separator") separator = node;
59
- if (node.type === "folder") {
60
- if (node.index?.url === url) {
61
- const items2 = [];
62
- if (separator) items2.push(separator);
63
- items2.push(node, node.index);
64
- return items2;
58
+ const items = [];
59
+ url = normalizeUrl(url);
60
+ function run(nodes2) {
61
+ let separator;
62
+ for (const node of nodes2) {
63
+ if (node.type === "separator") separator = node;
64
+ if (node.type === "folder") {
65
+ if (node.index?.url === url) {
66
+ if (separator) items.push(separator);
67
+ items.push(node, node.index);
68
+ return true;
69
+ }
70
+ if (run(node.children)) {
71
+ items.unshift(node);
72
+ if (separator) items.unshift(separator);
73
+ return true;
74
+ }
65
75
  }
66
- const items = searchPath(node.children, url);
67
- if (items) {
68
- items.unshift(node);
69
- if (separator) items.unshift(separator);
70
- return items;
76
+ if (node.type === "page" && node.url === url) {
77
+ if (separator) items.push(separator);
78
+ items.push(node);
79
+ return true;
71
80
  }
72
81
  }
73
- if (node.type === "page" && node.url === url) {
74
- const items = [];
75
- if (separator) items.push(separator);
76
- items.push(node);
77
- return items;
78
- }
82
+ return false;
79
83
  }
84
+ if (run(nodes)) return items;
80
85
  return null;
81
86
  }
82
87
  export {
@@ -37,11 +37,40 @@ function parseFolderPath(path) {
37
37
  path
38
38
  };
39
39
  }
40
+ function splitPath(path) {
41
+ return path.split("/").filter((p) => p.length > 0);
42
+ }
43
+ function joinPath(...paths) {
44
+ const out = [];
45
+ const parsed = paths.flatMap(splitPath);
46
+ for (const seg of parsed) {
47
+ switch (seg) {
48
+ case "..":
49
+ out.pop();
50
+ break;
51
+ case ".":
52
+ break;
53
+ default:
54
+ out.push(seg);
55
+ }
56
+ }
57
+ return out.join("/");
58
+ }
59
+ function slash(path) {
60
+ const isExtendedLengthPath = path.startsWith("\\\\?\\");
61
+ if (isExtendedLengthPath) {
62
+ return path;
63
+ }
64
+ return path.replaceAll("\\", "/");
65
+ }
40
66
 
41
67
  export {
42
68
  basename,
43
69
  extname,
44
70
  dirname,
45
71
  parseFilePath,
46
- parseFolderPath
72
+ parseFolderPath,
73
+ splitPath,
74
+ joinPath,
75
+ slash
47
76
  };
@@ -0,0 +1,11 @@
1
+ // src/utils/normalize-url.tsx
2
+ function normalizeUrl(url) {
3
+ if (url.startsWith("http://") || url.startsWith("https://")) return url;
4
+ if (!url.startsWith("/")) url = "/" + url;
5
+ if (url.length > 1 && url.endsWith("/")) url = url.slice(0, -1);
6
+ return url;
7
+ }
8
+
9
+ export {
10
+ normalizeUrl
11
+ };
@@ -2,10 +2,6 @@ import {
2
2
  flattenNode,
3
3
  remarkHeading
4
4
  } from "../chunk-QMATWJ5F.js";
5
- import {
6
- joinPath,
7
- slash
8
- } from "../chunk-3JSIVMCJ.js";
9
5
  import {
10
6
  defaultThemes,
11
7
  getHighlighter
@@ -520,7 +516,7 @@ function remarkImage({
520
516
  };
521
517
  }
522
518
  function getImportPath(file, dir) {
523
- const relative2 = slash(path.relative(dir, file));
519
+ const relative2 = path.relative(dir, file).replaceAll(path.sep, "/");
524
520
  return relative2.startsWith("../") ? relative2 : `./${relative2}`;
525
521
  }
526
522
  function parseSrc(src, publicDir, dir) {
@@ -535,7 +531,10 @@ function parseSrc(src, publicDir, dir) {
535
531
  if (src.startsWith("/")) {
536
532
  if (EXTERNAL_URL_REGEX.test(publicDir)) {
537
533
  const url = new URL(publicDir);
538
- url.pathname = joinPath(url.pathname, src);
534
+ const segs = [...url.pathname.split("/"), ...src.split("/")].filter(
535
+ (v) => v.length > 0
536
+ );
537
+ url.pathname = `/${segs.join("/")}`;
539
538
  return { type: "url", url };
540
539
  }
541
540
  return {
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  basename,
11
11
  extname
12
- } from "../chunk-7GNSIKII.js";
12
+ } from "../chunk-BDG7Y4PS.js";
13
13
  import "../chunk-JSBRDJBE.js";
14
14
 
15
15
  // src/search/server.ts
@@ -2,14 +2,15 @@ import {
2
2
  basename,
3
3
  dirname,
4
4
  extname,
5
- parseFilePath,
6
- parseFolderPath
7
- } from "../chunk-7GNSIKII.js";
8
- import {
9
5
  joinPath,
6
+ parseFilePath,
7
+ parseFolderPath,
10
8
  slash,
11
9
  splitPath
12
- } from "../chunk-3JSIVMCJ.js";
10
+ } from "../chunk-BDG7Y4PS.js";
11
+ import {
12
+ normalizeUrl
13
+ } from "../chunk-PFNP6PEB.js";
13
14
  import "../chunk-JSBRDJBE.js";
14
15
 
15
16
  // src/source/page-tree/legacy.ts
@@ -504,9 +505,10 @@ function createOutput(options) {
504
505
  baseUrl = "/",
505
506
  i18n,
506
507
  slugs: slugsFn,
507
- url: getUrl = createGetUrl(baseUrl ?? "/", i18n),
508
+ url: urlFn,
508
509
  transformers = []
509
510
  } = options;
511
+ const getUrl = urlFn ? (...args) => normalizeUrl(urlFn(...args)) : createGetUrl(baseUrl, i18n);
510
512
  const defaultLanguage = i18n?.defaultLanguage ?? "";
511
513
  const files = loadSource(source);
512
514
  const transformerSlugs = ({ storage }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.7.4",
3
+ "version": "15.7.6",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -92,8 +92,8 @@
92
92
  "dependencies": {
93
93
  "@formatjs/intl-localematcher": "^0.6.1",
94
94
  "@orama/orama": "^3.1.11",
95
- "@shikijs/rehype": "^3.11.0",
96
- "@shikijs/transformers": "^3.11.0",
95
+ "@shikijs/rehype": "^3.12.0",
96
+ "@shikijs/transformers": "^3.12.0",
97
97
  "github-slugger": "^2.0.0",
98
98
  "hast-util-to-estree": "^3.1.3",
99
99
  "hast-util-to-jsx-runtime": "^2.3.6",
@@ -105,34 +105,34 @@
105
105
  "remark-gfm": "^4.0.1",
106
106
  "remark-rehype": "^11.1.2",
107
107
  "scroll-into-view-if-needed": "^3.1.0",
108
- "shiki": "^3.11.0",
108
+ "shiki": "^3.12.0",
109
109
  "unist-util-visit": "^5.0.0"
110
110
  },
111
111
  "devDependencies": {
112
112
  "@mdx-js/mdx": "^3.1.0",
113
113
  "@mixedbread/sdk": "^0.26.0",
114
114
  "@oramacloud/client": "^2.1.4",
115
- "@tanstack/react-router": "^1.131.27",
115
+ "@tanstack/react-router": "^1.131.28",
116
116
  "@types/estree-jsx": "^1.0.5",
117
117
  "@types/hast": "^3.0.4",
118
118
  "@types/mdast": "^4.0.3",
119
119
  "@types/negotiator": "^0.6.4",
120
120
  "@types/node": "24.3.0",
121
- "@types/react": "^19.1.11",
122
- "@types/react-dom": "^19.1.7",
123
- "algoliasearch": "5.35.0",
121
+ "@types/react": "^19.1.12",
122
+ "@types/react-dom": "^19.1.8",
123
+ "algoliasearch": "5.36.0",
124
124
  "mdast-util-mdx-jsx": "^3.2.0",
125
125
  "mdast-util-mdxjs-esm": "^2.0.1",
126
- "next": "^15.5.0",
126
+ "next": "^15.5.2",
127
127
  "react-router": "^7.8.2",
128
128
  "remark-mdx": "^3.1.0",
129
129
  "remove-markdown": "^0.6.2",
130
130
  "typescript": "^5.9.2",
131
131
  "unified": "^11.0.5",
132
132
  "vfile": "^6.0.3",
133
- "waku": "^0.25.0",
134
- "tsconfig": "0.0.0",
135
- "eslint-config-custom": "0.0.0"
133
+ "waku": "^0.26.0",
134
+ "eslint-config-custom": "0.0.0",
135
+ "tsconfig": "0.0.0"
136
136
  },
137
137
  "peerDependencies": {
138
138
  "@mixedbread/sdk": "^0.19.0",
@@ -1,33 +0,0 @@
1
- // src/utils/path.ts
2
- function splitPath(path) {
3
- return path.split("/").filter((p) => p.length > 0);
4
- }
5
- function joinPath(...paths) {
6
- const out = [];
7
- const parsed = paths.flatMap(splitPath);
8
- for (const seg of parsed) {
9
- switch (seg) {
10
- case "..":
11
- out.pop();
12
- break;
13
- case ".":
14
- break;
15
- default:
16
- out.push(seg);
17
- }
18
- }
19
- return out.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
- joinPath,
32
- slash
33
- };