fumadocs-core 16.6.9 → 16.6.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.
@@ -1,11 +1,9 @@
1
- import "../../transformer-icon-BtBormWx.js";
2
1
  import { RehypeCodeOptions } from "../../mdx-plugins/rehype-code.js";
3
2
  import { RemarkImageOptions } from "../../mdx-plugins/remark-image.js";
4
3
  import { StructureOptions } from "../../mdx-plugins/remark-structure.js";
5
4
  import { RemarkHeadingOptions } from "../../mdx-plugins/remark-heading.js";
6
5
  import { RemarkCodeTabOptions } from "../../mdx-plugins/remark-code-tab.js";
7
6
  import { RemarkNpmOptions } from "../../mdx-plugins/remark-npm.js";
8
- import "../../mdx-plugins/index.js";
9
7
  import { t as ResolvePlugins } from "../../util-DJ5AvEKK.js";
10
8
  import { ProcessorOptions } from "@mdx-js/mdx";
11
9
 
@@ -1,11 +1,9 @@
1
- import "../../transformer-icon-BtBormWx.js";
2
1
  import { RehypeCodeOptions } from "../../mdx-plugins/rehype-code.js";
3
2
  import { RemarkImageOptions } from "../../mdx-plugins/remark-image.js";
4
3
  import { StructureOptions } from "../../mdx-plugins/remark-structure.js";
5
4
  import { RemarkHeadingOptions } from "../../mdx-plugins/remark-heading.js";
6
5
  import { RemarkCodeTabOptions } from "../../mdx-plugins/remark-code-tab.js";
7
6
  import { RemarkNpmOptions } from "../../mdx-plugins/remark-npm.js";
8
- import "../../mdx-plugins/index.js";
9
7
  import { t as ResolvePlugins } from "../../util-DJ5AvEKK.js";
10
8
  import { ProcessorOptions } from "@mdx-js/mdx";
11
9
 
@@ -1,6 +1,6 @@
1
1
  import { t as Awaitable } from "./types-BKxquRYN.js";
2
2
  import { I18nConfig } from "./i18n/index.js";
3
- import { i as LoaderConfig, o as LoaderOutput, u as Page } from "./path-B8CdvN3q.js";
3
+ import { i as LoaderConfig, o as LoaderOutput, u as Page } from "./path-oEC3g6wP.js";
4
4
  import { AdvancedIndex, AdvancedOptions, Dynamic, Index, SearchAPI, SimpleOptions } from "./search/server.js";
5
5
  import { Language, Orama, TypedDocument } from "@orama/orama";
6
6
 
@@ -128,15 +128,6 @@ interface ContentStoragePageFile<Config extends SourceConfig = SourceConfig> {
128
128
  slugs: string[];
129
129
  data: Config['pageData'];
130
130
  }
131
- /**
132
- * convert input files into virtual file system.
133
- *
134
- * in the storage, locale codes are removed from file paths, hence the same file will have same file paths in every storage.
135
- */
136
- declare function createContentStorageBuilder(loaderConfig: ResolvedLoaderConfig): {
137
- i18n(): Record<string, ContentStorage>;
138
- single(): ContentStorage;
139
- };
140
131
  //#endregion
141
132
  //#region src/source/page-tree/builder.d.ts
142
133
  interface PageTreeBuilderContext<Config extends SourceConfig = SourceConfig> {
@@ -213,6 +204,22 @@ declare class PageTreeBuilder {
213
204
  //#region src/source/plugins/icon.d.ts
214
205
  type IconResolver = (icon: string | undefined) => ReactNode;
215
206
  //#endregion
207
+ //#region src/source/loader/llms.d.ts
208
+ interface Context {
209
+ lang?: string;
210
+ }
211
+ interface LLMsConfig {
212
+ TAB?: string;
213
+ renderName?: (item: Node | Root, ctx: Context) => string;
214
+ renderDescription?: (item: Item | Folder, ctx: Context) => string;
215
+ }
216
+ declare function llms<C extends LoaderConfig>(loader: LoaderOutput<C>, config?: LLMsConfig): {
217
+ /**
218
+ * generate `llms.txt` content in Markdown format.
219
+ */
220
+ index: (lang?: string) => string;
221
+ };
222
+ //#endregion
216
223
  //#region src/source/loader.d.ts
217
224
  interface LoaderConfig {
218
225
  source: SourceConfig;
@@ -235,7 +242,7 @@ interface LoaderOptions<C extends LoaderConfig = LoaderConfig> {
235
242
  interface ResolvedLoaderConfig {
236
243
  source: Source;
237
244
  url: (slugs: string[], locale?: string) => string;
238
- plugins?: LoaderPlugin[];
245
+ plugins: LoaderPlugin[];
239
246
  pageTree?: Partial<PageTreeOptions>;
240
247
  i18n?: I18nConfig | undefined;
241
248
  }
@@ -389,4 +396,4 @@ declare function splitPath(path: string): string[];
389
396
  declare function joinPath(...paths: string[]): string;
390
397
  declare function slash(path: string): string;
391
398
  //#endregion
392
- export { _SourceUpdate_ as A, FileSystem as C, SourceConfig as D, Source as E, source as M, update as N, VirtualFile as O, createContentStorageBuilder as S, PageData as T, PageTreeTransformer as _, LoaderOptions as a, ContentStorageMetaFile as b, LoaderPluginOption as c, ResolvedLoaderConfig as d, createGetUrl as f, PageTreeOptions as g, PageTreeBuilderContext as h, LoaderConfig as i, multiple as j, _ConfigUnion_ as k, Meta as l, PageTreeBuilder as m, InferMetaType as n, LoaderOutput as o, loader as p, InferPageType as r, LoaderPlugin as s, path_d_exports as t, Page as u, ContentStorage as v, MetaData as w, ContentStoragePageFile as x, ContentStorageFile as y };
399
+ export { _ConfigUnion_ as A, ContentStoragePageFile as C, Source as D, PageData as E, multiple as M, source as N, SourceConfig as O, update as P, ContentStorageMetaFile as S, MetaData as T, PageTreeBuilderContext as _, LoaderOptions as a, ContentStorage as b, LoaderPluginOption as c, ResolvedLoaderConfig as d, createGetUrl as f, PageTreeBuilder as g, llms as h, LoaderConfig as i, _SourceUpdate_ as j, VirtualFile as k, Meta as l, LLMsConfig as m, InferMetaType as n, LoaderOutput as o, loader as p, InferPageType as r, LoaderPlugin as s, path_d_exports as t, Page as u, PageTreeOptions as v, FileSystem as w, ContentStorageFile as x, PageTreeTransformer as y };
@@ -1,10 +1,5 @@
1
- import "../definitions-VpSOvVeD.js";
2
- import "../utils-DWLhAKwM.js";
3
1
  import { BaseIndex } from "./algolia.js";
4
2
  import { SortedResult } from "./index.js";
5
- import "../create-i18n-7AVERQc8.js";
6
- import "../path-B8CdvN3q.js";
7
- import "./server.js";
8
3
  import { DependencyList } from "react";
9
4
  import { AnyOrama } from "@orama/orama";
10
5
  import { LiteClient, SearchResponse } from "algoliasearch/lite";
@@ -1,8 +1,4 @@
1
- import "../definitions-VpSOvVeD.js";
2
- import "../utils-DWLhAKwM.js";
3
1
  import { SortedResult } from "./index.js";
4
- import "../create-i18n-7AVERQc8.js";
5
- import "../path-B8CdvN3q.js";
6
2
  import { SearchAPI } from "./server.js";
7
3
  import Mixedbread from "@mixedbread/sdk";
8
4
  import { StoreSearchResponse } from "@mixedbread/sdk/resources/stores";
@@ -1,6 +1,4 @@
1
- import "../transformer-icon-BtBormWx.js";
2
1
  import { StructuredData } from "../mdx-plugins/remark-structure.js";
3
- import "../mdx-plugins/index.js";
4
2
  import { CloudManager } from "@oramacloud/client";
5
3
 
6
4
  //#region src/search/orama-cloud-legacy.d.ts
@@ -1,6 +1,4 @@
1
- import "../transformer-icon-BtBormWx.js";
2
1
  import { StructuredData } from "../mdx-plugins/remark-structure.js";
3
- import "../mdx-plugins/index.js";
4
2
  import { OramaCloud } from "@orama/core";
5
3
 
6
4
  //#region src/search/orama-cloud.d.ts
@@ -1,9 +1,6 @@
1
- import "../definitions-VpSOvVeD.js";
2
1
  import { StructuredData } from "../mdx-plugins/remark-structure.js";
3
- import "../utils-DWLhAKwM.js";
4
2
  import { HighlightedText, ReactSortedResult, SortedResult, createContentHighlighter } from "./index.js";
5
- import { a as advancedSchema, i as SimpleDocument, n as createFromSource, o as simpleSchema, r as AdvancedDocument, t as createI18nSearchAPI } from "../create-i18n-7AVERQc8.js";
6
- import "../path-B8CdvN3q.js";
3
+ import { a as advancedSchema, i as SimpleDocument, n as createFromSource, o as simpleSchema, r as AdvancedDocument, t as createI18nSearchAPI } from "../create-i18n-BakPYec9.js";
7
4
  import { Orama, RawData, SearchParams, create } from "@orama/orama";
8
5
 
9
6
  //#region src/search/server.d.ts
@@ -1,7 +1,4 @@
1
1
  import { i as Root } from "../../definitions-VpSOvVeD.js";
2
- import "../../utils-DWLhAKwM.js";
3
- import "../../page-tree/index.js";
4
-
5
2
  //#region src/source/client/index.d.ts
6
3
  interface SerializedPageTree {
7
4
  $fumadocs_loader: 'page-tree';
@@ -1,5 +1,3 @@
1
- import "../definitions-VpSOvVeD.js";
2
- import "../utils-DWLhAKwM.js";
3
- import { A as _SourceUpdate_, C as FileSystem, D as SourceConfig, E as Source, M as source, N as update, O as VirtualFile, S as createContentStorageBuilder, T as PageData, _ as PageTreeTransformer, a as LoaderOptions, b as ContentStorageMetaFile, c as LoaderPluginOption, d as ResolvedLoaderConfig, f as createGetUrl, g as PageTreeOptions, h as PageTreeBuilderContext, i as LoaderConfig, j as multiple, k as _ConfigUnion_, l as Meta, m as PageTreeBuilder, n as InferMetaType, o as LoaderOutput, p as loader, r as InferPageType, s as LoaderPlugin, t as path_d_exports, u as Page, v as ContentStorage, w as MetaData, x as ContentStoragePageFile, y as ContentStorageFile } from "../path-B8CdvN3q.js";
1
+ import { A as _ConfigUnion_, C as ContentStoragePageFile, D as Source, E as PageData, M as multiple, N as source, O as SourceConfig, P as update, S as ContentStorageMetaFile, T as MetaData, _ as PageTreeBuilderContext, a as LoaderOptions, b as ContentStorage, c as LoaderPluginOption, d as ResolvedLoaderConfig, f as createGetUrl, g as PageTreeBuilder, h as llms, i as LoaderConfig, j as _SourceUpdate_, k as VirtualFile, l as Meta, m as LLMsConfig, n as InferMetaType, o as LoaderOutput, p as loader, r as InferPageType, s as LoaderPlugin, t as path_d_exports, u as Page, v as PageTreeOptions, w as FileSystem, x as ContentStorageFile, y as PageTreeTransformer } from "../path-oEC3g6wP.js";
4
2
  import { getSlugs } from "./plugins/slugs.js";
5
- export { ContentStorage, ContentStorageFile, ContentStorageMetaFile, ContentStoragePageFile, FileSystem, InferMetaType, InferPageType, LoaderConfig, LoaderOptions, LoaderOutput, LoaderPlugin, LoaderPluginOption, Meta, MetaData, Page, PageData, type PageTreeBuilder, type PageTreeBuilderContext, type PageTreeOptions, type PageTreeTransformer, path_d_exports as PathUtils, ResolvedLoaderConfig, Source, SourceConfig, VirtualFile, _ConfigUnion_, _SourceUpdate_, createContentStorageBuilder, createGetUrl, getSlugs, loader, multiple, source, update };
3
+ export { type ContentStorage, type ContentStorageFile, type ContentStorageMetaFile, type ContentStoragePageFile, FileSystem, InferMetaType, InferPageType, LLMsConfig, LoaderConfig, LoaderOptions, LoaderOutput, LoaderPlugin, LoaderPluginOption, Meta, MetaData, Page, PageData, type PageTreeBuilder, type PageTreeBuilderContext, type PageTreeOptions, type PageTreeTransformer, path_d_exports as PathUtils, ResolvedLoaderConfig, Source, SourceConfig, VirtualFile, _ConfigUnion_, _SourceUpdate_, createGetUrl, getSlugs, llms, loader, multiple, source, update };
@@ -101,12 +101,13 @@ var FileSystem = class {
101
101
  return Array.from(this.files.keys());
102
102
  }
103
103
  makeDir(path) {
104
- const segments = splitPath(path);
105
- for (let i = 0; i < segments.length; i++) {
106
- const segment = segments.slice(0, i + 1).join("/");
107
- if (this.folders.has(segment)) continue;
108
- this.folders.set(segment, []);
109
- this.folders.get(dirname(segment)).push(segment);
104
+ const cur = [];
105
+ for (const seg of splitPath(path)) {
106
+ cur.push(seg);
107
+ const curPath = cur.join("/");
108
+ if (this.folders.has(curPath)) continue;
109
+ this.folders.set(curPath, []);
110
+ this.folders.get(dirname(curPath)).push(curPath);
110
111
  }
111
112
  }
112
113
  };
@@ -141,7 +142,7 @@ const EmptyLang = Symbol();
141
142
  * in the storage, locale codes are removed from file paths, hence the same file will have same file paths in every storage.
142
143
  */
143
144
  function createContentStorageBuilder(loaderConfig) {
144
- const { source, plugins = [], i18n } = loaderConfig;
145
+ const { source, plugins, i18n } = loaderConfig;
145
146
  const parser = i18n ? parsers[i18n.parser ?? "dot"] : parsers.none;
146
147
  const normalized = /* @__PURE__ */ new Map();
147
148
  for (const inputFile of source.files) {
@@ -160,12 +161,15 @@ function createContentStorageBuilder(loaderConfig) {
160
161
  data: inputFile.data
161
162
  };
162
163
  const [pathWithoutLocale, locale = i18n ? i18n.defaultLanguage : EmptyLang] = parser(file.path);
163
- const list = normalized.get(locale) ?? [];
164
+ let list = normalized.get(locale);
165
+ if (!list) {
166
+ list = [];
167
+ normalized.set(locale, list);
168
+ }
164
169
  list.push({
165
170
  pathWithoutLocale,
166
171
  file
167
172
  });
168
- normalized.set(locale, list);
169
173
  }
170
174
  function makeStorage(locale, inherit) {
171
175
  const storage = new FileSystem(inherit);
@@ -523,6 +527,65 @@ function pathToName(name) {
523
527
  return result.join("");
524
528
  }
525
529
 
530
+ //#endregion
531
+ //#region src/source/loader/llms.ts
532
+ function llms(loader, config = {}) {
533
+ const { TAB = " ", renderName = (node, ctx) => {
534
+ if (typeof node.name === "string") return node.name;
535
+ if ("type" in node && node.type === "page") {
536
+ const page = loader.getNodePage(node, ctx.lang);
537
+ if (page) return page.data.title ?? "";
538
+ }
539
+ return String(node.name);
540
+ }, renderDescription = (node, ctx) => {
541
+ if (typeof node.description === "string") return node.description;
542
+ if ("type" in node && node.type === "page") {
543
+ const page = loader.getNodePage(node, ctx.lang);
544
+ if (page) return page.data.description ?? "";
545
+ }
546
+ return String(node.description);
547
+ } } = config;
548
+ function index(lang) {
549
+ if (loader._i18n && lang === void 0) {
550
+ const { languages } = loader._i18n;
551
+ return languages.map(index).join("\n\n");
552
+ }
553
+ const pageTree = loader.getPageTree(lang);
554
+ const out = [];
555
+ const ctx = { lang };
556
+ out.push(`# ${renderName(pageTree, ctx)}`);
557
+ out.push("");
558
+ function item(name, description, indent) {
559
+ const prefix = TAB.repeat(indent);
560
+ description = description.trim();
561
+ if (description.length > 0) return `${prefix}- ${name}: ${description}`;
562
+ return `${prefix}- ${name}`;
563
+ }
564
+ function onNode(node, indent) {
565
+ switch (node.type) {
566
+ case "page":
567
+ out.push(item(formatMarkdownLink(renderName(node, ctx), node.url), renderDescription(node, ctx), indent));
568
+ break;
569
+ case "folder":
570
+ out.push(item(renderName(node, ctx), renderDescription(node, ctx), indent));
571
+ if (node.index) onNode(node.index, indent + 1);
572
+ for (const child of node.children) onNode(child, indent + 1);
573
+ break;
574
+ case "separator":
575
+ if (node.name) out.push(item(`**${renderName(node, ctx)}**`, "", indent));
576
+ out.push("");
577
+ break;
578
+ }
579
+ }
580
+ for (const child of pageTree.children) onNode(child, 0);
581
+ return out.join("\n");
582
+ }
583
+ return { index };
584
+ }
585
+ function formatMarkdownLink(title, url) {
586
+ return `[${title.replace(/([[\]])/g, "\\$1")}](${url.replace(/([()])/g, "\\$1")})`;
587
+ }
588
+
526
589
  //#endregion
527
590
  //#region src/source/loader.ts
528
591
  function createPageIndexer({ url }) {
@@ -596,7 +659,7 @@ function loader(...args) {
596
659
  let pageTrees;
597
660
  function getPageTrees() {
598
661
  if (pageTrees) return pageTrees;
599
- const { plugins = [], url, pageTree: pageTreeConfig } = loaderConfig;
662
+ const { plugins, url, pageTree: pageTreeConfig } = loaderConfig;
600
663
  const transformers = [];
601
664
  if (pageTreeConfig?.transformers) transformers.push(...pageTreeConfig.transformers);
602
665
  for (const plugin of plugins) if (plugin.transformPageTree) transformers.push(plugin.transformPageTree);
@@ -708,7 +771,7 @@ function resolveConfig(source, { slugs, icon, plugins = [], baseUrl, url, ...bas
708
771
  slugsPlugin(slugs)
709
772
  ])
710
773
  };
711
- for (const plugin of config.plugins ?? []) {
774
+ for (const plugin of config.plugins) {
712
775
  const result = plugin.config?.(config);
713
776
  if (result) config = result;
714
777
  }
@@ -728,4 +791,4 @@ function buildPlugins(plugins, sort = true) {
728
791
  }
729
792
 
730
793
  //#endregion
731
- export { FileSystem, path_exports as PathUtils, createGetUrl, getSlugs, loader, multiple, source, update };
794
+ export { FileSystem, path_exports as PathUtils, createGetUrl, getSlugs, llms, loader, multiple, source, update };
@@ -1,7 +1,4 @@
1
- import "../../definitions-VpSOvVeD.js";
2
- import "../../utils-DWLhAKwM.js";
3
- import { s as LoaderPlugin } from "../../path-B8CdvN3q.js";
4
- import "../index.js";
1
+ import { s as LoaderPlugin } from "../../path-oEC3g6wP.js";
5
2
  import { icons } from "lucide-react";
6
3
 
7
4
  //#region src/source/plugins/lucide-icons.d.ts
@@ -1,6 +1,4 @@
1
- import "../../definitions-VpSOvVeD.js";
2
- import "../../utils-DWLhAKwM.js";
3
- import { i as LoaderConfig, s as LoaderPlugin, x as ContentStoragePageFile } from "../../path-B8CdvN3q.js";
1
+ import { C as ContentStoragePageFile, i as LoaderConfig, s as LoaderPlugin } from "../../path-oEC3g6wP.js";
4
2
 
5
3
  //#region src/source/plugins/slugs.d.ts
6
4
  /**
@@ -1,6 +1,5 @@
1
1
  import { a as Separator$1, n as Item$1, t as Folder$1 } from "../../definitions-VpSOvVeD.js";
2
- import "../../utils-DWLhAKwM.js";
3
- import { s as LoaderPlugin } from "../../path-B8CdvN3q.js";
2
+ import { s as LoaderPlugin } from "../../path-oEC3g6wP.js";
4
3
  import { ReactNode } from "react";
5
4
 
6
5
  //#region src/source/plugins/status-badges.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.6.9",
3
+ "version": "16.6.10",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Docs",
@@ -118,8 +118,8 @@
118
118
  "dependencies": {
119
119
  "@formatjs/intl-localematcher": "^0.8.1",
120
120
  "@orama/orama": "^3.1.18",
121
- "@shikijs/rehype": "^4.0.0",
122
- "@shikijs/transformers": "^4.0.0",
121
+ "@shikijs/rehype": "^4.0.1",
122
+ "@shikijs/transformers": "^4.0.1",
123
123
  "estree-util-value-to-estree": "^3.5.0",
124
124
  "github-slugger": "^2.0.0",
125
125
  "hast-util-to-estree": "^3.1.3",
@@ -134,7 +134,7 @@
134
134
  "remark-gfm": "^4.0.1",
135
135
  "remark-rehype": "^11.1.2",
136
136
  "scroll-into-view-if-needed": "^3.1.0",
137
- "shiki": "^4.0.0",
137
+ "shiki": "^4.0.1",
138
138
  "tinyglobby": "^0.2.15",
139
139
  "unified": "^11.0.5",
140
140
  "unist-util-visit": "^5.1.0",
@@ -145,7 +145,7 @@
145
145
  "@mixedbread/sdk": "^0.56.0",
146
146
  "@orama/core": "^1.2.19",
147
147
  "@oramacloud/client": "^2.1.4",
148
- "@tanstack/react-router": "1.163.3",
148
+ "@tanstack/react-router": "1.166.2",
149
149
  "@types/estree-jsx": "^1.0.5",
150
150
  "@types/hast": "^3.0.4",
151
151
  "@types/mdast": "^4.0.4",
@@ -154,7 +154,7 @@
154
154
  "@types/react": "^19.2.14",
155
155
  "@types/react-dom": "^19.2.3",
156
156
  "algoliasearch": "5.49.1",
157
- "lucide-react": "^0.575.0",
157
+ "lucide-react": "^0.577.0",
158
158
  "next": "16.1.6",
159
159
  "react-router": "^7.13.1",
160
160
  "remark-directive": "^4.0.0",