fumadocs-core 15.7.6 → 15.7.8

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.
@@ -8,7 +8,9 @@ import { jsx } from "react/jsx-runtime";
8
8
  var Link2 = forwardRef(
9
9
  ({
10
10
  href = "#",
11
- external = !(href.startsWith("/") || href.startsWith("#") || href.startsWith(".")),
11
+ // any protocol
12
+ external = href.match(/^\w+:/) || // protocol relative URL
13
+ href.startsWith("//"),
12
14
  prefetch,
13
15
  ...props
14
16
  }, ref) => {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Link
4
- } from "./chunk-5SU2O5AS.js";
4
+ } from "./chunk-H2GMUTQG.js";
5
5
  import {
6
6
  useParams
7
7
  } from "./chunk-BBP7MIO4.js";
@@ -1,9 +1,9 @@
1
- import {
2
- defineI18n
3
- } from "../chunk-HUTQC33E.js";
4
1
  import {
5
2
  createI18nMiddleware
6
3
  } from "../chunk-KLUGJRZC.js";
4
+ import {
5
+ defineI18n
6
+ } from "../chunk-HUTQC33E.js";
7
7
  import "../chunk-JSBRDJBE.js";
8
8
  export {
9
9
  createI18nMiddleware,
package/dist/link.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Link
4
- } from "./chunk-5SU2O5AS.js";
4
+ } from "./chunk-H2GMUTQG.js";
5
5
  import "./chunk-BBP7MIO4.js";
6
6
  import "./chunk-JSBRDJBE.js";
7
7
  export {
@@ -193,4 +193,50 @@ interface CodeBlockAttributes<Name extends string = string> {
193
193
  */
194
194
  declare function parseCodeBlockAttributes<Name extends string = string>(meta: string, allowedNames?: Name[]): CodeBlockAttributes<Name>;
195
195
 
196
- export { type CodeBlockAttributes, type CodeBlockIcon, type CodeBlockTabsOptions, type RehypeCodeOptions, type RehypeTocOptions, type RemarkAdmonitionOptions, type RemarkImageOptions, type RemarkNpmOptions, type RemarkStepsOptions, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkImage, remarkNpm, remarkSteps, transformerIcon, transformerTab };
196
+ interface FileNode {
197
+ depth: number;
198
+ type: 'file';
199
+ name: string;
200
+ }
201
+ interface FolderNode {
202
+ depth: number;
203
+ type: 'folder';
204
+ name: string;
205
+ children: Node[];
206
+ }
207
+ type Node = FileNode | FolderNode;
208
+ interface RemarkMdxFilesOptions {
209
+ /**
210
+ * @defaultValue files
211
+ */
212
+ lang?: string;
213
+ toMdx?: (node: Node) => MdxJsxFlowElement;
214
+ }
215
+ /**
216
+ * Convert codeblocks with `files` as lang, like:
217
+ *
218
+ * ```files
219
+ * project
220
+ * ├── src
221
+ * │ ├── index.js
222
+ * │ └── utils
223
+ * │ └── helper.js
224
+ * ├── package.json
225
+ * ```
226
+ *
227
+ * into MDX `<Files />` component
228
+ */
229
+ declare function remarkMdxFiles(options?: RemarkMdxFilesOptions): Transformer<Root$1, Root$1>;
230
+
231
+ interface RemarkMdxMermaidOptions {
232
+ /**
233
+ * @defaultValue mermaid
234
+ */
235
+ lang?: string;
236
+ }
237
+ /**
238
+ * Convert `mermaid` codeblocks into `<Mermaid />` MDX component
239
+ */
240
+ declare function remarkMdxMermaid(options?: RemarkMdxMermaidOptions): Transformer<Root$1, Root$1>;
241
+
242
+ export { type CodeBlockAttributes, type CodeBlockIcon, type CodeBlockTabsOptions, type RehypeCodeOptions, type RehypeTocOptions, type RemarkAdmonitionOptions, type RemarkImageOptions, type RemarkMdxFilesOptions, type RemarkMdxMermaidOptions, type RemarkNpmOptions, type RemarkStepsOptions, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeToc, remarkAdmonition, remarkImage, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkSteps, transformerIcon, transformerTab };
@@ -1216,6 +1216,107 @@ function remarkNpm({
1216
1216
  });
1217
1217
  };
1218
1218
  }
1219
+
1220
+ // src/mdx-plugins/remark-mdx-files.ts
1221
+ import { visit as visit8 } from "unist-util-visit";
1222
+ function parseFileTree(code) {
1223
+ const lines = code.split(/\r?\n/);
1224
+ const stack = /* @__PURE__ */ new Map();
1225
+ for (const line of lines) {
1226
+ let depth = 0;
1227
+ let name = line;
1228
+ let match;
1229
+ while (match = /(?:├──|│|└──)\s*/.exec(name)) {
1230
+ name = name.slice(match[0].length);
1231
+ depth++;
1232
+ }
1233
+ if (!name) continue;
1234
+ const node = name.endsWith("/") ? { type: "folder", name, children: [], depth } : { type: "file", name, depth };
1235
+ let parent;
1236
+ for (let i = depth - 1; i >= 0 && !parent; i--) {
1237
+ parent = stack.get(i);
1238
+ }
1239
+ stack.set(depth, node);
1240
+ if (!parent) continue;
1241
+ if (parent.type === "file") {
1242
+ Object.assign(parent, {
1243
+ type: "folder",
1244
+ children: []
1245
+ });
1246
+ }
1247
+ parent.children.push(node);
1248
+ }
1249
+ return stack.get(0);
1250
+ }
1251
+ function defaultToMDX(node, depth = 0) {
1252
+ if (depth === 0) {
1253
+ return {
1254
+ type: "mdxJsxFlowElement",
1255
+ name: "Files",
1256
+ attributes: [],
1257
+ children: [defaultToMDX(node, depth + 1)]
1258
+ };
1259
+ }
1260
+ const attributes = [
1261
+ { type: "mdxJsxAttribute", name: "name", value: node.name }
1262
+ ];
1263
+ if (node.type === "file") {
1264
+ return {
1265
+ type: "mdxJsxFlowElement",
1266
+ attributes,
1267
+ children: [],
1268
+ name: "File"
1269
+ };
1270
+ }
1271
+ attributes.push({
1272
+ type: "mdxJsxAttribute",
1273
+ name: "defaultOpen",
1274
+ value: null
1275
+ });
1276
+ return {
1277
+ type: "mdxJsxFlowElement",
1278
+ attributes,
1279
+ name: "Folder",
1280
+ children: node.children.map((item) => defaultToMDX(item, depth + 1))
1281
+ };
1282
+ }
1283
+ function remarkMdxFiles(options = {}) {
1284
+ const { lang = "files", toMdx = defaultToMDX } = options;
1285
+ return (tree) => {
1286
+ visit8(tree, "code", (node) => {
1287
+ if (node.lang !== lang || !node.value) return;
1288
+ const fileTree = parseFileTree(node.value);
1289
+ if (!fileTree) return;
1290
+ Object.assign(node, toMdx(fileTree));
1291
+ });
1292
+ };
1293
+ }
1294
+
1295
+ // src/mdx-plugins/remark-mdx-mermaid.ts
1296
+ import { visit as visit9 } from "unist-util-visit";
1297
+ function toMDX(code) {
1298
+ return {
1299
+ type: "mdxJsxFlowElement",
1300
+ name: "Mermaid",
1301
+ attributes: [
1302
+ {
1303
+ type: "mdxJsxAttribute",
1304
+ name: "chart",
1305
+ value: code.trim()
1306
+ }
1307
+ ],
1308
+ children: []
1309
+ };
1310
+ }
1311
+ function remarkMdxMermaid(options = {}) {
1312
+ const { lang = "mermaid" } = options;
1313
+ return (tree) => {
1314
+ visit9(tree, "code", (node) => {
1315
+ if (node.lang !== lang || !node.value) return;
1316
+ Object.assign(node, toMDX(node.value));
1317
+ });
1318
+ };
1319
+ }
1219
1320
  export {
1220
1321
  generateCodeBlockTabs,
1221
1322
  parseCodeBlockAttributes,
@@ -1227,6 +1328,8 @@ export {
1227
1328
  default2 as remarkGfm,
1228
1329
  remarkHeading,
1229
1330
  remarkImage,
1331
+ remarkMdxFiles,
1332
+ remarkMdxMermaid,
1230
1333
  remarkNpm,
1231
1334
  remarkSteps,
1232
1335
  remarkStructure,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.7.6",
3
+ "version": "15.7.8",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -91,7 +91,7 @@
91
91
  ],
92
92
  "dependencies": {
93
93
  "@formatjs/intl-localematcher": "^0.6.1",
94
- "@orama/orama": "^3.1.11",
94
+ "@orama/orama": "^3.1.12",
95
95
  "@shikijs/rehype": "^3.12.0",
96
96
  "@shikijs/transformers": "^3.12.0",
97
97
  "github-slugger": "^2.0.0",
@@ -109,23 +109,23 @@
109
109
  "unist-util-visit": "^5.0.0"
110
110
  },
111
111
  "devDependencies": {
112
- "@mdx-js/mdx": "^3.1.0",
112
+ "@mdx-js/mdx": "^3.1.1",
113
113
  "@mixedbread/sdk": "^0.26.0",
114
114
  "@oramacloud/client": "^2.1.4",
115
- "@tanstack/react-router": "^1.131.28",
115
+ "@tanstack/react-router": "^1.131.30",
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
121
  "@types/react": "^19.1.12",
122
- "@types/react-dom": "^19.1.8",
122
+ "@types/react-dom": "^19.1.9",
123
123
  "algoliasearch": "5.36.0",
124
124
  "mdast-util-mdx-jsx": "^3.2.0",
125
125
  "mdast-util-mdxjs-esm": "^2.0.1",
126
126
  "next": "^15.5.2",
127
127
  "react-router": "^7.8.2",
128
- "remark-mdx": "^3.1.0",
128
+ "remark-mdx": "^3.1.1",
129
129
  "remove-markdown": "^0.6.2",
130
130
  "typescript": "^5.9.2",
131
131
  "unified": "^11.0.5",
@@ -142,6 +142,8 @@
142
142
  "next": "14.x.x || 15.x.x",
143
143
  "react": "18.x.x || 19.x.x",
144
144
  "react-dom": "18.x.x || 19.x.x",
145
+ "waku": "^0.26.0",
146
+ "@tanstack/react-router": "1.x.x",
145
147
  "react-router": "7.x.x"
146
148
  },
147
149
  "peerDependenciesMeta": {
@@ -168,6 +170,12 @@
168
170
  },
169
171
  "react-router": {
170
172
  "optional": true
173
+ },
174
+ "waku": {
175
+ "optional": true
176
+ },
177
+ "@tanstack/react-router": {
178
+ "optional": true
171
179
  }
172
180
  },
173
181
  "publishConfig": {