fumadocs-core 16.17.9 → 16.17.10

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.
@@ -74,13 +74,16 @@ var FileSystem = class {
74
74
  */
75
75
  function multiple(sources) {
76
76
  const out = {};
77
- for (const k in sources) out[k] = { files: sources[k].files.map((file) => ({
78
- ...file,
79
- data: {
80
- ...file.data,
81
- type: k
82
- }
83
- })) };
77
+ for (const k in sources) out[k] = {
78
+ ...sources[k],
79
+ files: sources[k].files.map((file) => ({
80
+ ...file,
81
+ data: {
82
+ ...file.data,
83
+ type: k
84
+ }
85
+ }))
86
+ };
84
87
  return out;
85
88
  }
86
89
  /**
package/dist/mcp.js CHANGED
@@ -33,7 +33,7 @@ function registerSourceTools(mcp, source, llms) {
33
33
  description: "Get the Markdown content of a docs page by its pathname (URL)",
34
34
  inputSchema: z.object({ url: z.string() })
35
35
  }, async ({ url }) => {
36
- const page = (typeof source === "function" ? await source() : source).getPageByUrl(url);
36
+ const page = findPage(typeof source === "function" ? await source() : source, url);
37
37
  if (!page) return {
38
38
  content: [{
39
39
  type: "text",
@@ -47,4 +47,12 @@ function registerSourceTools(mcp, source, llms) {
47
47
  }] };
48
48
  });
49
49
  }
50
+ /** URLs are unique across languages, an i18n loader looks them up per language */
51
+ function findPage(loader, url) {
52
+ if (!loader._i18n) return loader.getPageByUrl(url);
53
+ for (const language of loader._i18n.languages) {
54
+ const page = loader.getPageByUrl(url, language);
55
+ if (page) return page;
56
+ }
57
+ }
50
58
  export { registerSearchTool, registerSourceTools };
@@ -5,7 +5,7 @@ import path from "node:path";
5
5
  function parseFileTree(code) {
6
6
  const lines = code.split(/\r?\n/);
7
7
  const stack = /* @__PURE__ */ new Map();
8
- let root;
8
+ const roots = [];
9
9
  for (const line of lines) {
10
10
  const name = line.replace(/^[\s│├└─]+/, "");
11
11
  if (!name) continue;
@@ -25,7 +25,7 @@ function parseFileTree(code) {
25
25
  };
26
26
  stack.set(column, node);
27
27
  if (!parent) {
28
- root = node;
28
+ roots.push(node);
29
29
  continue;
30
30
  }
31
31
  if (parent.type === "file") Object.assign(parent, {
@@ -34,14 +34,20 @@ function parseFileTree(code) {
34
34
  });
35
35
  parent.children.push(node);
36
36
  }
37
- return root;
37
+ if (roots.length <= 1) return roots[0];
38
+ return {
39
+ type: "folder",
40
+ name: "",
41
+ children: roots,
42
+ depth: -1
43
+ };
38
44
  }
39
45
  function defaultToMDX(node, options, depth = 0) {
40
46
  if (depth === 0) return {
41
47
  type: "mdxJsxFlowElement",
42
48
  name: "Files",
43
49
  attributes: [],
44
- children: [defaultToMDX(node, options, depth + 1)]
50
+ children: node.type === "folder" && node.name === "" ? node.children.map((item) => defaultToMDX(item, options, depth + 1)) : [defaultToMDX(node, options, depth + 1)]
45
51
  };
46
52
  const attributes = [{
47
53
  type: "mdxJsxAttribute",
@@ -1 +1 @@
1
- export { t as dynamicLoader } from "../dynamic-B2QN5ycX.js";
1
+ export { t as dynamicLoader } from "../dynamic-BKMu5hc8.js";
@@ -1,5 +1,5 @@
1
1
  import { o as path_exports } from "../path-CH9Umap3.js";
2
- import { a as update, i as multiple, n as createGetUrl, o as FileSystem, r as loader, t as dynamicLoader } from "../dynamic-B2QN5ycX.js";
2
+ import { a as update, i as multiple, n as createGetUrl, o as FileSystem, r as loader, t as dynamicLoader } from "../dynamic-BKMu5hc8.js";
3
3
  import { getSlugs } from "./plugins/slugs.js";
4
4
  import { llms } from "./llms.js";
5
5
  export { FileSystem, path_exports as PathUtils, createGetUrl, dynamicLoader, getSlugs, llms, loader, multiple, update };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.17.9",
3
+ "version": "16.17.10",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Docs",