fumadocs-core 16.19.0 → 16.19.2

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.
Files changed (47) hide show
  1. package/dist/{algolia-BU6WTadf.d.ts → algolia-DpOwaSi1.d.ts} +1 -1
  2. package/dist/{client-D5_Oxm3d.d.ts → client-Di7LtHdh.d.ts} +2 -2
  3. package/dist/content/mdx/preset-bundler.d.ts +1 -1
  4. package/dist/content/mdx/preset-runtime.d.ts +1 -1
  5. package/dist/framework/plugin.d.ts +1 -1
  6. package/dist/{index--VTdzHy3.d.ts → index-DKOSCE6a.d.ts} +1 -1
  7. package/dist/{index-xpLrpK8K.d.ts → index-F4pIhBFU.d.ts} +36 -2
  8. package/dist/mcp.d.ts +2 -2
  9. package/dist/mcp.js +1 -9
  10. package/dist/mdx-plugins/index.d.ts +2 -2
  11. package/dist/mdx-plugins/remark-gfm.d.ts +1 -1
  12. package/dist/mdx-plugins/remark-image.js +7 -7
  13. package/dist/mdx-plugins/remark-include.js +4 -4
  14. package/dist/{meilisearch-C4oclDaO.d.ts → meilisearch-MtURSSXp.d.ts} +1 -1
  15. package/dist/{mixedbread-8oiVgbAM.d.ts → mixedbread-CA3Xv15h.d.ts} +2 -2
  16. package/dist/remark-gfm-chhuRhmk.d.ts +2 -0
  17. package/dist/search/algolia.d.ts +1 -1
  18. package/dist/search/client/algolia.d.ts +1 -1
  19. package/dist/search/client/docs-search.d.ts +1 -1
  20. package/dist/search/client/fetch.d.ts +1 -1
  21. package/dist/search/client/flexsearch-static.d.ts +1 -1
  22. package/dist/search/client/meilisearch.d.ts +1 -1
  23. package/dist/search/client/mixedbread.d.ts +2 -2
  24. package/dist/search/client/orama-cloud-legacy.d.ts +1 -1
  25. package/dist/search/client/orama-cloud.d.ts +1 -1
  26. package/dist/search/client/orama-static.d.ts +1 -1
  27. package/dist/search/client/orama-static.js +3 -3
  28. package/dist/search/client.d.ts +1 -1
  29. package/dist/search/flexsearch.d.ts +2 -2
  30. package/dist/search/meilisearch.d.ts +1 -1
  31. package/dist/search/mixedbread.d.ts +2 -2
  32. package/dist/search/orama-cloud-legacy.d.ts +1 -1
  33. package/dist/search/orama-cloud.d.ts +2 -2
  34. package/dist/search/server.d.ts +1 -1
  35. package/dist/{server-CazrloBV.d.ts → server-D3xLyaLr.d.ts} +1 -1
  36. package/dist/server.d.ts +1 -1
  37. package/dist/server.js +26 -15
  38. package/dist/source/dynamic.d.ts +1 -1
  39. package/dist/source/index.d.ts +1 -1
  40. package/dist/source/llms.d.ts +1 -1
  41. package/dist/source/llms.js +136 -20
  42. package/dist/source/plugins/lucide-icons.d.ts +1 -1
  43. package/dist/source/plugins/slugs.d.ts +1 -1
  44. package/dist/source/plugins/slugs.js +5 -5
  45. package/dist/source/plugins/status-badges.d.ts +1 -1
  46. package/package.json +6 -6
  47. package/dist/remark-gfm-DpVfAX1x.d.ts +0 -2
@@ -1,5 +1,5 @@
1
1
  import { n as StructuredData } from "./remark-structure-CV606E7e.js";
2
- import { D as LoaderOutput, T as LoaderConfig } from "./index-xpLrpK8K.js";
2
+ import { D as LoaderOutput, T as LoaderConfig } from "./index-F4pIhBFU.js";
3
3
  import { t as Awaitable } from "./types-Dvkw0Kd0.js";
4
4
  import { Algoliasearch } from "algoliasearch";
5
5
  interface DocumentRecord {
@@ -1,7 +1,7 @@
1
1
  import { r as SortedResult } from "./index-BlFx9iJj.js";
2
2
  import { t as Awaitable } from "./types-Dvkw0Kd0.js";
3
- import { t as BaseIndex } from "./algolia-BU6WTadf.js";
4
- import "./mixedbread-8oiVgbAM.js";
3
+ import { t as BaseIndex } from "./algolia-DpOwaSi1.js";
4
+ import "./mixedbread-CA3Xv15h.js";
5
5
  import { DependencyList } from "react";
6
6
  import { AnyZBSearch, SearchParams } from "zbsearch";
7
7
  import { Root } from "hast";
@@ -4,7 +4,7 @@ import { t as StructureOptions } from "../../remark-structure-CV606E7e.js";
4
4
  import { t as RemarkHeadingOptions } from "../../remark-heading-BfD2dpns.js";
5
5
  import { t as RemarkCodeTabOptions } from "../../remark-code-tab-Bp3EItqr.js";
6
6
  import { t as RemarkNpmOptions } from "../../remark-npm-IH35Vls_.js";
7
- import "../../index--VTdzHy3.js";
7
+ import "../../index-DKOSCE6a.js";
8
8
  import { t as ResolvePlugins } from "../../util-YfkucgkA.js";
9
9
  import { Pluggable } from "unified";
10
10
  import { ProcessorOptions } from "@mdx-js/mdx";
@@ -4,7 +4,7 @@ import { t as StructureOptions } from "../../remark-structure-CV606E7e.js";
4
4
  import { t as RemarkHeadingOptions } from "../../remark-heading-BfD2dpns.js";
5
5
  import { t as RemarkCodeTabOptions } from "../../remark-code-tab-Bp3EItqr.js";
6
6
  import { t as RemarkNpmOptions } from "../../remark-npm-IH35Vls_.js";
7
- import "../../index--VTdzHy3.js";
7
+ import "../../index-DKOSCE6a.js";
8
8
  import { t as ResolvePlugins } from "../../util-YfkucgkA.js";
9
9
  import { ProcessorOptions } from "@mdx-js/mdx";
10
10
  export type MDXRuntimePresetOptions = Omit<NonNullable<ProcessorOptions>, 'rehypePlugins' | 'remarkPlugins'> & {
@@ -1,6 +1,6 @@
1
1
  import { i as TranslationExtension } from "../index-DFrWGSeW.js";
2
2
  import { n as StructuredData } from "../remark-structure-CV606E7e.js";
3
- import { D as LoaderOutput, E as LoaderOptions, T as LoaderConfig, k as LoaderPluginOption } from "../index-xpLrpK8K.js";
3
+ import { D as LoaderOutput, E as LoaderOptions, T as LoaderConfig, k as LoaderPluginOption } from "../index-F4pIhBFU.js";
4
4
  import { c as TOCItemType } from "../toc-BuHOTlzj.js";
5
5
  import { ReactNode } from "react";
6
6
  type Awaitable<T> = T | Promise<T>;
@@ -1,4 +1,4 @@
1
- import "./remark-gfm-DpVfAX1x.js";
1
+ import "./remark-gfm-chhuRhmk.js";
2
2
  import "./rehype-code-Czh_8L5z.js";
3
3
  import "./remark-image-BwyGdFld.js";
4
4
  import "./remark-include-D_FmDdtI.js";
@@ -3,7 +3,7 @@ import { n as I18nConfig } from "./index-DFrWGSeW.js";
3
3
  import { n as StructuredData } from "./remark-structure-CV606E7e.js";
4
4
  import { a as Separator, i as Root, n as Item, r as Node, t as Folder } from "./definitions-BQVehOBz.js";
5
5
  import { n as SerializedPageTree } from "./index-B2EN5xn0.js";
6
- import "./index--VTdzHy3.js";
6
+ import "./index-DKOSCE6a.js";
7
7
  import "./index-DMxrC6WS.js";
8
8
  import { ReactNode } from "react";
9
9
  /**
@@ -549,11 +549,28 @@ interface LLMsConfig<Page = unknown> {
549
549
  TAB?: string;
550
550
  renderName?: (item: Node | Root, ctx: Context) => string;
551
551
  renderDescription?: (item: Root | Item | Folder, ctx: Context) => string;
552
+ /**
553
+ * The URL of a link, in files `item.url` is the path of the file it links to, like the `.md` file of a page.
554
+ */
552
555
  renderUrl?: (item: Item, ctx: Context) => string;
553
556
  /**
554
- * Render a page as Markdown, required by `page()` and `full()`.
557
+ * Render a page as Markdown, required by `page()`, `full()` and the files.
555
558
  */
556
559
  renderPage?: (page: Page) => Awaitable<string>;
560
+ /**
561
+ * The pages in `full()` and the files, every page by default.
562
+ */
563
+ filter?: (page: Page) => boolean;
564
+ /**
565
+ * Whether a folder is a section: a folder with its own `llms-full.txt`. Root folders are sections by default.
566
+ *
567
+ * - `collapse`: list the section in `llms.txt` as one link to its own `llms.txt`, which lists its pages.
568
+ * - `asPath`: the path to serve its files under, instead of the URL of the folder's index page.
569
+ */
570
+ section?: (folder: Folder, ctx: Context) => boolean | {
571
+ asPath?: string;
572
+ collapse?: boolean;
573
+ };
557
574
  }
558
575
  interface LLMs<IndexOutput extends Awaitable<string> = Awaitable<string>> {
559
576
  /**
@@ -576,6 +593,23 @@ interface LLMsWithPages<Page, IndexOutput extends Awaitable<string> = Awaitable<
576
593
  * generate `llms-full.txt` content: every page rendered with `renderPage`.
577
594
  */
578
595
  full: (lang?: string) => Promise<string>;
596
+ /**
597
+ * The paths of the files for agents, for static output:
598
+ *
599
+ * - `/llms.txt`: the index, with a link to the `.md` file of each page.
600
+ * - `/llms-full.txt`: every page.
601
+ * - `<page>.md`: a page, `/index.md` for `/`.
602
+ * - `<section>/llms-full.txt`: the pages of a section, and `<section>/llms.txt` when it's collapsed, see `section`.
603
+ *
604
+ * @param lang - only the pages of a language, required when URLs don't have the locale (`hideLocale: 'always'`)
605
+ */
606
+ files: (lang?: string) => Promise<string[]>;
607
+ /**
608
+ * Respond with the file at a path, `undefined` when there's none.
609
+ *
610
+ * @param lang - only the pages of a language, see `files()`
611
+ */
612
+ serve: (path: string, lang?: string) => Promise<Response | undefined>;
579
613
  }
580
614
  declare function llms<C extends LoaderConfig = LoaderConfig>(input: LoaderOutput<C>, config: LLMsConfig<C['page']> & {
581
615
  renderPage: (page: C['page']) => Awaitable<string>;
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as SearchServer } from "./server-CazrloBV.js";
2
- import { D as LoaderOutput, T as LoaderConfig, r as LLMsWithPages } from "./index-xpLrpK8K.js";
1
+ import { r as SearchServer } from "./server-D3xLyaLr.js";
2
+ import { D as LoaderOutput, T as LoaderConfig, r as LLMsWithPages } from "./index-F4pIhBFU.js";
3
3
  import { t as Awaitable } from "./types-Dvkw0Kd0.js";
4
4
  import { McpServer } from "@modelcontextprotocol/server";
5
5
  /**
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 = findPage(typeof source === "function" ? await source() : source, url);
36
+ const page = (typeof source === "function" ? await source() : source).getPageByUrl(url.replace(/[?#].*$/, ""));
37
37
  if (!page) return {
38
38
  content: [{
39
39
  type: "text",
@@ -47,12 +47,4 @@ 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
- }
58
50
  export { registerSearchTool, registerSourceTools };
@@ -1,4 +1,4 @@
1
- import { n as remarkGfm, t as RemarkGfmOptions } from "../remark-gfm-DpVfAX1x.js";
1
+ import { n as remarkGfm, t as RemarkGfmOptions } from "../remark-gfm-chhuRhmk.js";
2
2
  import { o as transformerTab } from "../rehype-code.core-BeCtKe7K.js";
3
3
  import { r as transformerIcon, t as CodeBlockIcon } from "../transformer-icon-Bi4LROAz.js";
4
4
  import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-Czh_8L5z.js";
@@ -18,5 +18,5 @@ import { n as remarkMdxMermaid, t as RemarkMdxMermaidOptions } from "../remark-m
18
18
  import { n as RemarkFeedbackBlockOptions, r as remarkFeedbackBlock, t as FeedbackBlockProps } from "../remark-feedback-block-2Ei4IDr4.js";
19
19
  import { t as remarkShow } from "../remark-show-uR9rtiVe.js";
20
20
  import { t as LLMsOptions } from "../remark-llms-BCyfmS02.js";
21
- import "../index--VTdzHy3.js";
21
+ import "../index-DKOSCE6a.js";
22
22
  export { CodeBlockAttributes, type CodeBlockIcon, CodeBlockTabsOptions, FeedbackBlockProps, type LLMsOptions, RehypeCodeOptions, RehypeTOCItemType, RehypeTocOptions, RemarkAdmonitionOptions, RemarkCodeTabOptions, RemarkDirectiveAdmonitionOptions, RemarkFeedbackBlockOptions, type RemarkGfmOptions, RemarkHeadingOptions, RemarkImageOptions, RemarkIncludeOptions, type RemarkMdxFilesOptions, RemarkMdxMermaidOptions, RemarkNpmOptions, RemarkStepsOptions, StructureOptions, StructuredData, StructuredDataContent, extractCodeRegion, generateCodeBlockTabs, parseCodeBlockAttributes, rehypeCode, rehypeCodeDefaultOptions, rehypeHeading, rehypeToc, remarkAdmonition, remarkCodeTab, remarkDirectiveAdmonition, remarkFeedbackBlock, remarkGfm, remarkHeading, remarkImage, remarkInclude, remarkMdxFiles, remarkMdxMermaid, remarkNpm, remarkShow, remarkSteps, remarkStructure, remarkStructureDefaultOptions, structure, transformerIcon, transformerTab };
@@ -1,2 +1,2 @@
1
- import { n as remarkGfm, t as RemarkGfmOptions } from "../remark-gfm-DpVfAX1x.js";
1
+ import { n as remarkGfm, t as RemarkGfmOptions } from "../remark-gfm-chhuRhmk.js";
2
2
  export { type RemarkGfmOptions, remarkGfm };
@@ -1,6 +1,6 @@
1
1
  import { replaceSource } from "./stringifier.js";
2
2
  import { u as walk } from "../utils-DfA1qEJN.js";
3
- import * as path$1 from "node:path";
3
+ import * as path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  // src/mdx-plugins/remark-image.ts
6
6
  const VALID_BLUR_EXT = [
@@ -14,7 +14,7 @@ const EXTERNAL_URL_REGEX = /^https?:\/\//;
14
14
  /**
15
15
  * Turn images into Next.js Image compatible usage.
16
16
  */
17
- function remarkImage({ placeholder = "none", external = true, useImport = true, onError = "error", publicDir = path$1.join(process.cwd(), "public") } = {}) {
17
+ function remarkImage({ placeholder = "none", external = true, useImport = true, onError = "error", publicDir = path.join(process.cwd(), "public") } = {}) {
18
18
  return async (tree, file) => {
19
19
  const importsToInject = [];
20
20
  const promises = [];
@@ -150,9 +150,9 @@ function importedUrl(name) {
150
150
  };
151
151
  }
152
152
  function getImportPath(file, dir) {
153
- const relative = path$1.relative(dir, file);
154
- const posix = relative.replaceAll(path$1.sep, "/");
155
- if (path$1.isAbsolute(relative) || posix.startsWith("../")) return posix;
153
+ const relative = path.relative(dir, file);
154
+ const posix = relative.replaceAll(path.sep, "/");
155
+ if (path.isAbsolute(relative) || posix.startsWith("../")) return posix;
156
156
  return `./${posix}`;
157
157
  }
158
158
  /**
@@ -180,7 +180,7 @@ function parseSrc(src, publicDir, dir) {
180
180
  }
181
181
  return {
182
182
  type: "file",
183
- file: path$1.join(publicDir, src)
183
+ file: path.join(publicDir, src)
184
184
  };
185
185
  }
186
186
  if (!dir) {
@@ -189,7 +189,7 @@ function parseSrc(src, publicDir, dir) {
189
189
  }
190
190
  return {
191
191
  type: "file",
192
- file: path$1.join(dir, src)
192
+ file: path.join(dir, src)
193
193
  };
194
194
  }
195
195
  async function getImageSize(src, onExternal) {
@@ -3,7 +3,7 @@ import { n as headingIdRegex } from "../heading-id-DV5jeAL8.js";
3
3
  import { embedSource, replaceSource } from "./stringifier.js";
4
4
  import { r as flattenNode, u as walk } from "../utils-DfA1qEJN.js";
5
5
  import Slugger from "github-slugger";
6
- import * as path$1 from "node:path";
6
+ import * as path from "node:path";
7
7
  import * as fs from "node:fs/promises";
8
8
  // src/mdx-plugins/remark-include.ts
9
9
  const elementLikeTypes = /* @__PURE__ */ new Set([
@@ -30,7 +30,7 @@ function remarkInclude({ getProcessor = () => this } = {}) {
30
30
  if (!specifier) return "skip";
31
31
  const attributes = parseElementAttributes(node);
32
32
  const idx = specifier.lastIndexOf("#");
33
- const targetPath = path$1.resolve("cwd" in attributes ? file.cwd : dir, idx === -1 ? specifier : specifier.slice(0, idx));
33
+ const targetPath = path.resolve("cwd" in attributes ? file.cwd : dir, idx === -1 ? specifier : specifier.slice(0, idx));
34
34
  const section = idx === -1 ? void 0 : specifier.slice(idx + 1);
35
35
  const host = parent;
36
36
  const target = host?.type === "paragraph" ? host : node;
@@ -52,7 +52,7 @@ function remarkInclude({ getProcessor = () => this } = {}) {
52
52
  } catch (e) {
53
53
  throw new Error(`failed to read file ${targetPath}\n${e instanceof Error ? e.message : String(e)}`, { cause: e });
54
54
  }
55
- const ext = path$1.extname(targetPath);
55
+ const ext = path.extname(targetPath);
56
56
  if (attributes.lang || ext !== ".md" && ext !== ".mdx") {
57
57
  const lang = attributes.lang ?? ext.slice(1);
58
58
  const value = section ? extractCodeRegion(content, section) : content.replace(/\r?\n$/, "");
@@ -76,7 +76,7 @@ function remarkInclude({ getProcessor = () => this } = {}) {
76
76
  tree.children = children;
77
77
  }
78
78
  embedSource(file, target, source, tree.children);
79
- await update(tree, path$1.dirname(targetPath), file, [...stack, targetPath]);
79
+ await update(tree, path.dirname(targetPath), file, [...stack, targetPath]);
80
80
  return tree;
81
81
  }
82
82
  return (tree, file) => update(tree, file.dirname ?? file.cwd, file, []);
@@ -1,5 +1,5 @@
1
1
  import { n as StructuredData } from "./remark-structure-CV606E7e.js";
2
- import { D as LoaderOutput, T as LoaderConfig } from "./index-xpLrpK8K.js";
2
+ import { D as LoaderOutput, T as LoaderConfig } from "./index-F4pIhBFU.js";
3
3
  import { t as Awaitable } from "./types-Dvkw0Kd0.js";
4
4
  import { Meilisearch } from "meilisearch";
5
5
  interface DocumentRecord {
@@ -1,6 +1,6 @@
1
1
  import { r as SortedResult } from "./index-BlFx9iJj.js";
2
- import { n as SearchAPI } from "./server-CazrloBV.js";
3
- import { t as DocumentRecord } from "./meilisearch-C4oclDaO.js";
2
+ import { n as SearchAPI } from "./server-D3xLyaLr.js";
3
+ import { t as DocumentRecord } from "./meilisearch-MtURSSXp.js";
4
4
  import Mixedbread from "@mixedbread/sdk";
5
5
  import { ScoredTextInputChunk } from "@mixedbread/sdk/resources/stores";
6
6
  /**
@@ -0,0 +1,2 @@
1
+ import remarkGfm, { Options as RemarkGfmOptions } from "remark-gfm";
2
+ export { remarkGfm as n, RemarkGfmOptions as t };
@@ -1,2 +1,2 @@
1
- import { a as sync, i as setIndexSettings, n as DocumentRecord, o as toDocuments, r as SyncOptions, s as updateDocuments, t as BaseIndex } from "../algolia-BU6WTadf.js";
1
+ import { a as sync, i as setIndexSettings, n as DocumentRecord, o as toDocuments, r as SyncOptions, s as updateDocuments, t as BaseIndex } from "../algolia-DpOwaSi1.js";
2
2
  export { BaseIndex, DocumentRecord, SyncOptions, setIndexSettings, sync, toDocuments, updateDocuments };
@@ -1,2 +1,2 @@
1
- import { b as useAlgoliaSearch, v as AlgoliaOptions, y as algoliaClient } from "../../client-D5_Oxm3d.js";
1
+ import { b as useAlgoliaSearch, v as AlgoliaOptions, y as algoliaClient } from "../../client-Di7LtHdh.js";
2
2
  export { AlgoliaOptions, algoliaClient, useAlgoliaSearch };
@@ -1,2 +1,2 @@
1
- import { n as SearchClient, r as useDocsSearch, t as ClientPreset } from "../../client-D5_Oxm3d.js";
1
+ import { n as SearchClient, r as useDocsSearch, t as ClientPreset } from "../../client-Di7LtHdh.js";
2
2
  export { ClientPreset, SearchClient, useDocsSearch };
@@ -1,2 +1,2 @@
1
- import { D as useFetchSearch, E as fetchClient, T as FetchOptions } from "../../client-D5_Oxm3d.js";
1
+ import { D as useFetchSearch, E as fetchClient, T as FetchOptions } from "../../client-Di7LtHdh.js";
2
2
  export { FetchOptions, fetchClient, useFetchSearch };
@@ -1,2 +1,2 @@
1
- import { a as flexsearchStaticClient, i as FlexsearchStaticOptions, o as useFlexsearchStatic } from "../../client-D5_Oxm3d.js";
1
+ import { a as flexsearchStaticClient, i as FlexsearchStaticOptions, o as useFlexsearchStatic } from "../../client-Di7LtHdh.js";
2
2
  export { FlexsearchStaticOptions, flexsearchStaticClient, useFlexsearchStatic };
@@ -1,2 +1,2 @@
1
- import { f as MeilisearchOptions, m as useMeilisearch, p as meilisearchClient } from "../../client-D5_Oxm3d.js";
1
+ import { f as MeilisearchOptions, m as useMeilisearch, p as meilisearchClient } from "../../client-Di7LtHdh.js";
2
2
  export { MeilisearchOptions, meilisearchClient, useMeilisearch };
@@ -1,3 +1,3 @@
1
- import { c as mixedbreadClient, s as MixedbreadOptions } from "../../client-D5_Oxm3d.js";
2
- import { n as SearchMetadata } from "../../mixedbread-8oiVgbAM.js";
1
+ import { c as mixedbreadClient, s as MixedbreadOptions } from "../../client-Di7LtHdh.js";
2
+ import { n as SearchMetadata } from "../../mixedbread-CA3Xv15h.js";
3
3
  export { MixedbreadOptions, type SearchMetadata, mixedbreadClient };
@@ -1,2 +1,2 @@
1
- import { d as useOramaCloudLegacySearch, l as OramaCloudLegacyOptions, u as oramaCloudLegacyClient } from "../../client-D5_Oxm3d.js";
1
+ import { d as useOramaCloudLegacySearch, l as OramaCloudLegacyOptions, u as oramaCloudLegacyClient } from "../../client-Di7LtHdh.js";
2
2
  export { OramaCloudLegacyOptions, oramaCloudLegacyClient, useOramaCloudLegacySearch };
@@ -1,2 +1,2 @@
1
- import { _ as useOramaCloudSearch, g as oramaCloudClient, h as OramaCloudOptions } from "../../client-D5_Oxm3d.js";
1
+ import { _ as useOramaCloudSearch, g as oramaCloudClient, h as OramaCloudOptions } from "../../client-Di7LtHdh.js";
2
2
  export { OramaCloudOptions, oramaCloudClient, useOramaCloudSearch };
@@ -1,2 +1,2 @@
1
- import { C as staticClient, S as oramaStaticClient, w as useStaticSearch, x as StaticOptions } from "../../client-D5_Oxm3d.js";
1
+ import { C as staticClient, S as oramaStaticClient, w as useStaticSearch, x as StaticOptions } from "../../client-Di7LtHdh.js";
2
2
  export { StaticOptions, oramaStaticClient, staticClient, useStaticSearch };
@@ -4,7 +4,7 @@ import { n as join, t as BASE_PATH } from "../../url-BF81yL4m.js";
4
4
  import { useCallback, useRef } from "react";
5
5
  import { create, load } from "zbsearch";
6
6
  // src/search/client/orama-static.ts
7
- const cache$1 = /* @__PURE__ */ new Map();
7
+ const cache = /* @__PURE__ */ new Map();
8
8
  async function loadDB(from, initDB = () => create({ schema: { _: "string" } })) {
9
9
  const res = await fetch(from);
10
10
  if (!res.ok) throw new Error(`failed to fetch exported search indexes from ${from}, make sure the search database is exported and available for client.`);
@@ -39,10 +39,10 @@ async function loadDB(from, initDB = () => create({ schema: { _: "string" } }))
39
39
  }
40
40
  function getDBCached({ from = join(BASE_PATH, "/api/search"), initDB, initOrama }) {
41
41
  const cacheKey = from;
42
- const cached = cache$1.get(cacheKey);
42
+ const cached = cache.get(cacheKey);
43
43
  if (cached) return cached;
44
44
  const result = loadDB(from, initDB ?? initOrama);
45
- cache$1.set(cacheKey, result);
45
+ cache.set(cacheKey, result);
46
46
  return result;
47
47
  }
48
48
  async function searchStatic(options, query) {
@@ -1,2 +1,2 @@
1
- import { A as SearchResultRecord, D as useFetchSearch, F as useSearch, M as UseSearchOptions, N as UseSearchReturn, O as SearchResult, P as useHighlightQuery, T as FetchOptions, _ as useOramaCloudSearch, b as useAlgoliaSearch, f as MeilisearchOptions, h as OramaCloudOptions, j as SearchResultTable, k as SearchResultItem, m as useMeilisearch, n as SearchClient, r as useDocsSearch, t as ClientPreset, v as AlgoliaOptions, w as useStaticSearch, x as StaticOptions } from "../client-D5_Oxm3d.js";
1
+ import { A as SearchResultRecord, D as useFetchSearch, F as useSearch, M as UseSearchOptions, N as UseSearchReturn, O as SearchResult, P as useHighlightQuery, T as FetchOptions, _ as useOramaCloudSearch, b as useAlgoliaSearch, f as MeilisearchOptions, h as OramaCloudOptions, j as SearchResultTable, k as SearchResultItem, m as useMeilisearch, n as SearchClient, r as useDocsSearch, t as ClientPreset, v as AlgoliaOptions, w as useStaticSearch, x as StaticOptions } from "../client-Di7LtHdh.js";
2
2
  export { type AlgoliaOptions, type ClientPreset, type FetchOptions, type MeilisearchOptions, type OramaCloudOptions, type SearchClient, type SearchResult, type SearchResultItem, type SearchResultRecord, type SearchResultTable, type StaticOptions, type UseSearchOptions, type UseSearchReturn, useSearch as experimental_useSearch, useAlgoliaSearch, useDocsSearch, useFetchSearch, useHighlightQuery, useMeilisearch, useOramaCloudSearch, useStaticSearch };
@@ -1,5 +1,5 @@
1
- import { m as SharedIndex, n as SearchAPI, t as QueryOptions } from "../server-CazrloBV.js";
2
- import { D as LoaderOutput, T as LoaderConfig } from "../index-xpLrpK8K.js";
1
+ import { m as SharedIndex, n as SearchAPI, t as QueryOptions } from "../server-D3xLyaLr.js";
2
+ import { D as LoaderOutput, T as LoaderConfig } from "../index-F4pIhBFU.js";
3
3
  import { t as Awaitable } from "../types-Dvkw0Kd0.js";
4
4
  import { n as I18nConfig } from "../index-DFrWGSeW.js";
5
5
  import "../index-BlFx9iJj.js";
@@ -1,2 +1,2 @@
1
- import { a as toDocuments, i as sync, n as MeilisearchDocument, r as SyncOptions, t as DocumentRecord } from "../meilisearch-C4oclDaO.js";
1
+ import { a as toDocuments, i as sync, n as MeilisearchDocument, r as SyncOptions, t as DocumentRecord } from "../meilisearch-MtURSSXp.js";
2
2
  export { DocumentRecord, MeilisearchDocument, SyncOptions, sync, toDocuments };
@@ -1,3 +1,3 @@
1
- import { a as toDocuments, t as DocumentRecord } from "../meilisearch-C4oclDaO.js";
2
- import { a as sync, i as createMixedbreadSearchAPI, n as SearchMetadata, r as SyncOptions, t as MixedbreadSearchOptions } from "../mixedbread-8oiVgbAM.js";
1
+ import { a as toDocuments, t as DocumentRecord } from "../meilisearch-MtURSSXp.js";
2
+ import { a as sync, i as createMixedbreadSearchAPI, n as SearchMetadata, r as SyncOptions, t as MixedbreadSearchOptions } from "../mixedbread-CA3Xv15h.js";
3
3
  export { type DocumentRecord, MixedbreadSearchOptions, SearchMetadata, SyncOptions, createMixedbreadSearchAPI, sync, toDocuments };
@@ -1,5 +1,5 @@
1
1
  import { n as StructuredData } from "../remark-structure-CV606E7e.js";
2
- import "../index--VTdzHy3.js";
2
+ import "../index-DKOSCE6a.js";
3
3
  import { CloudManager } from "@oramacloud/client";
4
4
  export interface SyncOptions {
5
5
  /**
@@ -1,6 +1,6 @@
1
- import "../index--VTdzHy3.js";
1
+ import "../index-DKOSCE6a.js";
2
2
  import { n as StructuredData } from "../remark-structure-CV606E7e.js";
3
- import { D as LoaderOutput, T as LoaderConfig } from "../index-xpLrpK8K.js";
3
+ import { D as LoaderOutput, T as LoaderConfig } from "../index-F4pIhBFU.js";
4
4
  import { t as Awaitable } from "../types-Dvkw0Kd0.js";
5
5
  import { OramaCloud } from "@orama/core";
6
6
  export interface SyncOptions {
@@ -1,2 +1,2 @@
1
- import { a as AdvancedOptions, c as SimpleOptions, d as createSearchAPI, f as initAdvancedSearch, i as AdvancedIndex, l as createFromSource, n as SearchAPI, o as ExportedData, p as initSimpleSearch, r as SearchServer, s as Index, t as QueryOptions, u as createI18nSearchAPI } from "../server-CazrloBV.js";
1
+ import { a as AdvancedOptions, c as SimpleOptions, d as createSearchAPI, f as initAdvancedSearch, i as AdvancedIndex, l as createFromSource, n as SearchAPI, o as ExportedData, p as initSimpleSearch, r as SearchServer, s as Index, t as QueryOptions, u as createI18nSearchAPI } from "../server-D3xLyaLr.js";
2
2
  export { AdvancedIndex, AdvancedOptions, ExportedData, Index, QueryOptions, SearchAPI, SearchServer, SimpleOptions, createFromSource, createI18nSearchAPI, createSearchAPI, initAdvancedSearch, initSimpleSearch };
@@ -1,5 +1,5 @@
1
1
  import { n as I18nConfig } from "./index-DFrWGSeW.js";
2
- import { D as LoaderOutput, T as LoaderConfig } from "./index-xpLrpK8K.js";
2
+ import { D as LoaderOutput, T as LoaderConfig } from "./index-F4pIhBFU.js";
3
3
  import { n as StructuredData } from "./remark-structure-CV606E7e.js";
4
4
  import { t as Awaitable } from "./types-Dvkw0Kd0.js";
5
5
  import { r as SortedResult } from "./index-BlFx9iJj.js";
package/dist/server.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare function renderToMarkdown(node: ReactNode, { target }?: {
17
17
  export declare function renderRoute(element: ReactElement): Promise<string | undefined>;
18
18
  /**
19
19
  * Resolve the MDX components of a generated Markdown component (`remarkLLMs` with `output: 'function'`):
20
- * a missing component becomes a stub that `renderToMarkdown` serializes as JSX syntax.
20
+ * a missing component is serialized as JSX syntax by `renderToMarkdown`.
21
21
  */
22
22
  export declare function jsxComponents(components: Record<string, ElementType> | undefined): Record<string, ElementType>;
23
23
  export type MarkdownTag = (strings: TemplateStringsArray, ...values: ReactNode[]) => Promise<string>;
package/dist/server.js CHANGED
@@ -43,16 +43,25 @@ async function renderRoute(element) {
43
43
  if (result !== NOT_OPTED_IN) return renderToMarkdown(result);
44
44
  }
45
45
  /**
46
+ * The element types of `jsxComponents()`, each stands for a component under its MDX tag: a component kept as JSX is
47
+ * named after its tag, as function names are minified in production builds and a component can have several tags.
48
+ */
49
+ const tagged = /* @__PURE__ */ new WeakMap();
50
+ /**
46
51
  * Resolve the MDX components of a generated Markdown component (`remarkLLMs` with `output: 'function'`):
47
- * a missing component becomes a stub that `renderToMarkdown` serializes as JSX syntax.
52
+ * a missing component is serialized as JSX syntax by `renderToMarkdown`.
48
53
  */
49
54
  function jsxComponents(components) {
50
- return new Proxy(components ?? {}, { get(target, key) {
51
- const value = target[key];
52
- if (value !== void 0 || typeof key !== "string") return value;
53
- const stub = () => null;
54
- stub.displayName = key;
55
- return stub;
55
+ return new Proxy({}, { get(_, key) {
56
+ if (typeof key !== "string") return;
57
+ const type = components?.[key] ?? (() => null);
58
+ if (typeof type === "string") return type;
59
+ const element = () => null;
60
+ tagged.set(element, {
61
+ tag: key,
62
+ type
63
+ });
64
+ return element;
56
65
  } });
57
66
  }
58
67
  /**
@@ -144,24 +153,26 @@ async function walk(node, state) {
144
153
  if (typeof node === "object" && Symbol.iterator in node) return (await Promise.all(Array.from(node, (child) => walk(child, state)))).join("");
145
154
  return "";
146
155
  }
147
- async function element(type, props, state) {
156
+ async function element(type, props, state, tag) {
157
+ const entry = tagged.get(type);
158
+ if (entry) return element(entry.type, props, state, entry.tag);
148
159
  if (typeof type === "string") return host(type, props, state);
149
- if (isClientReference(type)) return jsx(clientReferenceName(type.$$id), props, state);
150
- if (typeof type === "function") return component(type, props, state);
160
+ if (isClientReference(type)) return jsx(tag ?? clientReferenceName(type.$$id), props, state);
161
+ if (typeof type === "function") return component(type, props, state, tag);
151
162
  if (typeof type === "symbol") return walk(props.children, state);
152
163
  if (typeof type === "object" && type !== null) {
153
164
  const special = type;
154
165
  switch (special.$$typeof) {
155
- case REACT_LAZY: return element(await resolveLazy(special), props, state);
156
- case REACT_MEMO: return element(special.type, props, state);
157
- case REACT_FORWARD_REF: return component(special.render, props, state);
166
+ case REACT_LAZY: return element(await resolveLazy(special), props, state, tag);
167
+ case REACT_MEMO: return element(special.type, props, state, tag);
168
+ case REACT_FORWARD_REF: return component(special.render, props, state, tag);
158
169
  }
159
170
  }
160
171
  return "";
161
172
  }
162
- async function component(fn, props, state) {
173
+ async function component(fn, props, state, tag) {
163
174
  const result = await optIn(fn, props, state.target);
164
- if (result === NOT_OPTED_IN) return jsx(componentName(fn), props, state);
175
+ if (result === NOT_OPTED_IN) return jsx(tag ?? componentName(fn), props, state);
165
176
  return walk(result, state);
166
177
  }
167
178
  function componentName(fn) {
@@ -1,2 +1,2 @@
1
- import { b as DynamicLoaderConfig, x as dynamicLoader, y as DynamicLoader } from "../index-xpLrpK8K.js";
1
+ import { b as DynamicLoaderConfig, x as dynamicLoader, y as DynamicLoader } from "../index-F4pIhBFU.js";
2
2
  export { DynamicLoader, DynamicLoaderConfig, dynamicLoader };
@@ -1,2 +1,2 @@
1
- import { A as Meta, C as InferMetaType, D as LoaderOutput, E as LoaderOptions, F as types_d_exports, G as ContentStorage, H as PageTreeBuilderContext, J as FileSystem, K as ContentStorageMetaFile, M as ResolvedLoaderConfig, N as createGetUrl, O as LoaderPlugin, P as loader, R as getSlugs, S as GetPageOptions, T as LoaderConfig, U as PageTreeOptions, V as PageTreeBuilder, W as PageTreeTransformer, _ as multiple, a as StaticParamsOptions, b as DynamicLoaderConfig, c as path_d_exports, d as PageData, f as Params, g as VirtualFile, h as StaticSource, i as llms, j as Page, k as LoaderPluginOption, l as DynamicSource, m as SourceUnion, n as LLMsConfig, o as getStaticParams, p as Source, q as ContentStoragePageFile, r as LLMsWithPages, s as isDynamicPath, t as LLMs, u as MetaData, v as update, w as InferPageType, x as dynamicLoader, y as DynamicLoader } from "../index-xpLrpK8K.js";
1
+ import { A as Meta, C as InferMetaType, D as LoaderOutput, E as LoaderOptions, F as types_d_exports, G as ContentStorage, H as PageTreeBuilderContext, J as FileSystem, K as ContentStorageMetaFile, M as ResolvedLoaderConfig, N as createGetUrl, O as LoaderPlugin, P as loader, R as getSlugs, S as GetPageOptions, T as LoaderConfig, U as PageTreeOptions, V as PageTreeBuilder, W as PageTreeTransformer, _ as multiple, a as StaticParamsOptions, b as DynamicLoaderConfig, c as path_d_exports, d as PageData, f as Params, g as VirtualFile, h as StaticSource, i as llms, j as Page, k as LoaderPluginOption, l as DynamicSource, m as SourceUnion, n as LLMsConfig, o as getStaticParams, p as Source, q as ContentStoragePageFile, r as LLMsWithPages, s as isDynamicPath, t as LLMs, u as MetaData, v as update, w as InferPageType, x as dynamicLoader, y as DynamicLoader } from "../index-F4pIhBFU.js";
2
2
  export { type ContentStorage, type ContentStorageMetaFile, type ContentStoragePageFile, type DynamicLoader, type DynamicLoaderConfig, type DynamicSource, FileSystem, GetPageOptions, InferMetaType, InferPageType, LLMs, LLMsConfig, LLMsWithPages, LoaderConfig, LoaderOptions, LoaderOutput, LoaderPlugin, LoaderPluginOption, Meta, type MetaData, Page, type PageData, type PageTreeBuilder, type PageTreeBuilderContext, type PageTreeOptions, type PageTreeTransformer, type Params, path_d_exports as PathUtils, ResolvedLoaderConfig, type Source, type SourceUnion, type StaticParamsOptions, type StaticSource, type VirtualFile, type types_d_exports as _Internal, createGetUrl, dynamicLoader, getSlugs, getStaticParams, isDynamicPath, llms, loader, multiple, update };
@@ -1,2 +1,2 @@
1
- import { i as llms, n as LLMsConfig, r as LLMsWithPages, t as LLMs } from "../index-xpLrpK8K.js";
1
+ import { i as llms, n as LLMsConfig, r as LLMsWithPages, t as LLMs } from "../index-F4pIhBFU.js";
2
2
  export { LLMs, LLMsConfig, LLMsWithPages, llms };
@@ -1,6 +1,6 @@
1
1
  // src/source/llms.ts
2
2
  function llms(input, config = {}) {
3
- const { TAB = " " } = config;
3
+ const { TAB = " ", filter = () => true, section = (folder) => Boolean(folder.root) } = config;
4
4
  function renderName(node, ctx) {
5
5
  if (config.renderName) return config.renderName(node, ctx);
6
6
  if (node.type === "page") {
@@ -31,10 +31,20 @@ function llms(input, config = {}) {
31
31
  }
32
32
  function formatNode(node, indent, ctx) {
33
33
  switch (node.type) {
34
- case "page": return formatListItem(formatMarkdownLink(renderName(node, ctx), config.renderUrl?.(node, ctx) ?? node.url), renderDescription(node, ctx), indent);
34
+ case "page": {
35
+ const page = ctx.markdown && ctx.loader.getNodePage(node, ctx.lang);
36
+ if (page && filter(page)) node = {
37
+ ...node,
38
+ url: markdownPath(page.url)
39
+ };
40
+ return formatListItem(formatMarkdownLink(renderName(node, ctx), config.renderUrl?.(node, ctx) ?? node.url), renderDescription(node, ctx), indent);
41
+ }
35
42
  case "folder": {
36
- const out = [];
37
- out.push(formatListItem(renderName(node, ctx), renderDescription(node, ctx), indent));
43
+ const scope = ctx.markdown ? sectionOf(node, ctx) : void 0;
44
+ let name = renderName(node, ctx);
45
+ if (scope) name = linkFile(name, `${scope.url}/${scope.collapse ? "llms" : "llms-full"}.txt`, ctx);
46
+ const out = [formatListItem(name, renderDescription(node, ctx), indent)];
47
+ if (scope?.collapse) return out[0];
38
48
  if (node.index) out.push(formatNode(node.index, indent + 1, ctx));
39
49
  for (const child of node.children) out.push(formatNode(child, indent + 1, ctx));
40
50
  return out.join("\n");
@@ -42,34 +52,118 @@ function llms(input, config = {}) {
42
52
  case "separator": return "\n" + formatListItem(`**${renderName(node, ctx) || "Separator"}**`, "", indent);
43
53
  }
44
54
  }
45
- function formatIndex(loader, lang) {
55
+ function formatIndex(ctx) {
56
+ const { loader, lang } = ctx;
46
57
  if (loader._i18n && lang === void 0) {
47
58
  const out = [];
48
- for (const language of loader._i18n.languages) out.push(formatIndex(loader, language));
59
+ for (const language of loader._i18n.languages) out.push(formatIndex({
60
+ ...ctx,
61
+ lang: language
62
+ }));
49
63
  return out.join("\n\n");
50
64
  }
51
- const ctx = {
52
- lang,
53
- loader
54
- };
55
- const pageTree = loader.getPageTree(lang);
56
- const out = [];
57
- out.push(`# ${renderName(pageTree, ctx)}`, "");
58
- const description = renderDescription(pageTree, ctx);
65
+ return formatTree(loader.getPageTree(lang), ctx);
66
+ }
67
+ /** the index of a page tree or a section, `full` is the path of its `llms-full.txt` */
68
+ function formatTree(node, ctx, full) {
69
+ const out = [`# ${renderName(node, ctx)}`, ""];
70
+ const description = renderDescription(node, ctx);
59
71
  if (description) out.push(`> ${description}`, "");
60
- for (const child of pageTree.children) out.push(formatNode(child, 0, ctx));
72
+ if (full) out.push(linkFile("All pages", full, ctx), "");
73
+ if (node.type === "folder" && node.index) out.push(formatNode(node.index, 0, ctx));
74
+ for (const child of node.children) out.push(formatNode(child, 0, ctx));
61
75
  return out.join("\n");
62
76
  }
77
+ /** a link to one of the files, through `renderUrl` */
78
+ function linkFile(name, path, ctx) {
79
+ const item = {
80
+ type: "page",
81
+ name,
82
+ url: path
83
+ };
84
+ return formatMarkdownLink(name, config.renderUrl?.(item, ctx) ?? path);
85
+ }
63
86
  function renderPage(page) {
64
87
  if (!config.renderPage) throw new Error("`renderPage` is required by `page()` and `full()`, see llms() options.");
65
88
  return config.renderPage(page);
66
89
  }
90
+ async function renderPages(pages) {
91
+ return (await Promise.all(pages.map(renderPage))).join("\n\n");
92
+ }
93
+ const getPages = (loader, lang) => loader.getPages(lang).filter(filter);
94
+ /** the URL, collapse and pages of a folder, when it's a section */
95
+ function sectionOf(folder, ctx) {
96
+ const options = section(folder, ctx);
97
+ if (!options) return;
98
+ const pages = [];
99
+ const visit = (node) => {
100
+ if (node.type === "page") {
101
+ const page = ctx.loader.getNodePage(node, ctx.lang);
102
+ if (page && filter(page)) pages.push(page);
103
+ } else if (node.type === "folder") {
104
+ if (node.index) visit(node.index);
105
+ for (const child of node.children) visit(child);
106
+ }
107
+ };
108
+ visit(folder);
109
+ if (pages.length === 0) return;
110
+ const { asPath, collapse } = options === true ? {} : options;
111
+ let url = asPath ?? folder.index?.url ?? pages[0].url;
112
+ if (!asPath) for (const page of pages) while (url.length > 0 && !`${page.url}/`.startsWith(`${url}/`)) url = url.slice(0, url.lastIndexOf("/"));
113
+ return {
114
+ url: url.replace(/\/$/, ""),
115
+ collapse,
116
+ pages,
117
+ folder,
118
+ ctx
119
+ };
120
+ }
121
+ /** the sections of the page trees, by URL */
122
+ function sections(loader, lang) {
123
+ const out = /* @__PURE__ */ new Map();
124
+ const visit = (node, ctx) => {
125
+ if (node.type !== "folder") return;
126
+ const scope = sectionOf(node, ctx);
127
+ if (scope && !out.has(scope.url)) out.set(scope.url, scope);
128
+ for (const child of node.children) visit(child, ctx);
129
+ };
130
+ const languages = lang === void 0 && loader._i18n ? loader._i18n.languages : [lang];
131
+ for (const language of languages) for (const child of loader.getPageTree(language).children) visit(child, {
132
+ loader,
133
+ lang: language
134
+ });
135
+ return out;
136
+ }
67
137
  function withLoader(render) {
68
138
  if (typeof input === "function") return Promise.resolve(input()).then(render);
69
139
  return render(input);
70
140
  }
141
+ async function renderFile(loader, path, lang) {
142
+ if (path === "/llms.txt") return formatIndex({
143
+ loader,
144
+ lang,
145
+ markdown: true
146
+ });
147
+ if (path === "/llms-full.txt") return renderPages(getPages(loader, lang));
148
+ if (path.endsWith(".md")) {
149
+ let url = path.slice(0, -3).replace(/(.)\/$/, "$1");
150
+ if (url === "/index") url = "/";
151
+ const page = loader.getPageByUrl(url, lang) ?? loader.getPageByUrl(`${url}/`, lang);
152
+ if (page && filter(page)) return renderPage(page);
153
+ return;
154
+ }
155
+ const scope = sections(loader, lang).get(path.slice(0, path.lastIndexOf("/")));
156
+ if (scope && path.endsWith("/llms-full.txt")) return renderPages(scope.pages);
157
+ if (scope?.collapse && path.endsWith("/llms.txt")) return formatTree(scope.folder, {
158
+ ...scope.ctx,
159
+ markdown: true
160
+ }, `${scope.url}/llms-full.txt`);
161
+ }
71
162
  return {
72
- index: (lang) => withLoader((loader) => formatIndex(loader, lang)),
163
+ index: (lang) => withLoader((loader) => formatIndex({
164
+ loader,
165
+ lang
166
+ })),
73
167
  indexNode: (node, lang) => withLoader((loader) => formatNode(node, 0, {
74
168
  lang,
75
169
  loader
@@ -78,13 +172,35 @@ function llms(input, config = {}) {
78
172
  return renderPage(page);
79
173
  },
80
174
  async full(lang) {
81
- const loader = typeof input === "function" ? await input() : input;
82
- const rendered = [];
83
- for (const page of loader.getPages(lang)) rendered.push(renderPage(page));
84
- return (await Promise.all(rendered)).join("\n\n");
175
+ return withLoader((loader) => renderPages(getPages(loader, lang)));
176
+ },
177
+ async files(lang) {
178
+ return withLoader((loader) => {
179
+ const pages = getPages(loader, lang);
180
+ const out = /* @__PURE__ */ new Set(["/llms.txt", "/llms-full.txt"]);
181
+ for (const page of pages) out.add(markdownPath(page.url));
182
+ for (const [url, { collapse }] of sections(loader, lang)) {
183
+ if (collapse) out.add(`${url}/llms.txt`);
184
+ out.add(`${url}/llms-full.txt`);
185
+ }
186
+ return Array.from(out);
187
+ });
188
+ },
189
+ async serve(path, lang) {
190
+ if (!/\.(md|txt)$/.test(path)) return;
191
+ return withLoader(async (loader) => {
192
+ const encoded = encodeURI(path);
193
+ const text = await renderFile(loader, path, lang) ?? (encoded === path ? void 0 : await renderFile(loader, encoded, lang));
194
+ if (text === void 0) return;
195
+ return new Response(text, { headers: { "Content-Type": `${path.endsWith(".md") ? "text/markdown" : "text/plain"}; charset=utf-8` } });
196
+ });
85
197
  }
86
198
  };
87
199
  }
200
+ /** the path of the `.md` file of a page: `<page>.md`, `/index.md` for `/` */
201
+ function markdownPath(url) {
202
+ return url === "/" ? "/index.md" : `${url.replace(/\/$/, "")}.md`;
203
+ }
88
204
  function formatMarkdownLink(title, url) {
89
205
  return `[${title.replace(/([[\]])/g, "\\$1")}](${url.replace(/([()])/g, "\\$1")})`;
90
206
  }
@@ -1,4 +1,4 @@
1
- import { O as LoaderPlugin } from "../../index-xpLrpK8K.js";
1
+ import { O as LoaderPlugin } from "../../index-F4pIhBFU.js";
2
2
  import { icons } from "lucide-react";
3
3
  /**
4
4
  * Convert icon names into Lucide Icons, requires `lucide-react` to be installed.
@@ -1,2 +1,2 @@
1
- import { B as slugsPlugin, I as SlugFn, L as SlugsPluginOptions, R as getSlugs, z as slugsFromData } from "../../index-xpLrpK8K.js";
1
+ import { B as slugsPlugin, I as SlugFn, L as SlugsPluginOptions, R as getSlugs, z as slugsFromData } from "../../index-F4pIhBFU.js";
2
2
  export { SlugFn, SlugsPluginOptions, getSlugs, slugsFromData, slugsPlugin };
@@ -15,7 +15,7 @@ function slugsPlugin(optsOrFn = {}) {
15
15
  name: "fumadocs:slugs",
16
16
  transformStorage({ storage }) {
17
17
  const indexFiles = [];
18
- const taken = /* @__PURE__ */ new Set();
18
+ const taken = /* @__PURE__ */ new Map();
19
19
  for (const [path, file] of storage.files) {
20
20
  if (file.format !== "page") continue;
21
21
  if (file.slugs) {
@@ -31,8 +31,8 @@ function slugsPlugin(optsOrFn = {}) {
31
31
  }
32
32
  file.slugs = generateSlugs(path, file);
33
33
  const key = file.slugs.join("/");
34
- if (taken.has(key)) throw new Error(`Duplicated slugs: ${key}`);
35
- taken.add(key);
34
+ if (taken.has(key)) throw new Error(`Duplicated slugs "${key}" of ${taken.get(key)} and ${path}`);
35
+ taken.set(key, path);
36
36
  }
37
37
  for (const path of indexFiles) {
38
38
  const file = storage.read(path);
@@ -40,8 +40,8 @@ function slugsPlugin(optsOrFn = {}) {
40
40
  file.slugs = generateSlugs(path, file);
41
41
  if (taken.has(file.slugs.join("/"))) file.slugs = [...file.slugs, "index"];
42
42
  const key = file.slugs.join("/");
43
- if (taken.has(key)) throw new Error(`Duplicated slugs: ${key}`);
44
- taken.add(key);
43
+ if (taken.has(key)) throw new Error(`Duplicated slugs "${key}" of ${taken.get(key)} and ${path}`);
44
+ taken.set(key, path);
45
45
  }
46
46
  }
47
47
  };
@@ -1,4 +1,4 @@
1
- import { O as LoaderPlugin } from "../../index-xpLrpK8K.js";
1
+ import { O as LoaderPlugin } from "../../index-F4pIhBFU.js";
2
2
  import { a as Separator$1, n as Item$1, t as Folder$1 } from "../../definitions-BQVehOBz.js";
3
3
  import { ReactNode } from "react";
4
4
  export interface Item extends Item$1 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.19.0",
3
+ "version": "16.19.2",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Docs",
@@ -147,7 +147,7 @@
147
147
  "@modelcontextprotocol/server": "2.4.0",
148
148
  "@orama/core": "^1.2.19",
149
149
  "@oramacloud/client": "^2.1.4",
150
- "@pierre/highlights": "^0.4.0",
150
+ "@pierre/highlights": "^0.5.0",
151
151
  "@shikijs/transformers": "^4.6.0",
152
152
  "@tanstack/react-router": "1.170.46",
153
153
  "@types/estree-jsx": "^1.0.5",
@@ -156,12 +156,12 @@
156
156
  "@types/node": "26.6.6",
157
157
  "@types/react": "^19.3.0",
158
158
  "@types/react-dom": "^19.3.0",
159
- "algoliasearch": "5.61.0",
159
+ "algoliasearch": "5.64.0",
160
160
  "flexsearch": "^0.8.212",
161
161
  "hast-util-to-jsx-runtime": "^2.3.7",
162
- "lucide-react": "^1.70.0",
163
- "meilisearch": "0.62.0",
164
- "next": "16.4.5",
162
+ "lucide-react": "^1.71.0",
163
+ "meilisearch": "0.63.0",
164
+ "next": "16.4.6",
165
165
  "path-to-regexp": "^9.0.0",
166
166
  "react-router": "^8.5.1",
167
167
  "rehype-raw": "^7.0.0",
@@ -1,2 +0,0 @@
1
- import remarkGfm$1, { Options as RemarkGfmOptions } from "remark-gfm";
2
- export { remarkGfm$1 as n, RemarkGfmOptions as t };