fumadocs-core 16.19.1 → 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 (32) hide show
  1. package/dist/{algolia-CQ_t21WZ.d.ts → algolia-DpOwaSi1.d.ts} +1 -1
  2. package/dist/{client-Ca0pBjkk.d.ts → client-Di7LtHdh.d.ts} +2 -2
  3. package/dist/framework/plugin.d.ts +1 -1
  4. package/dist/{index-DqVvRMMI.d.ts → index-F4pIhBFU.d.ts} +13 -2
  5. package/dist/mcp.d.ts +2 -2
  6. package/dist/{meilisearch-BngEnZgG.d.ts → meilisearch-MtURSSXp.d.ts} +1 -1
  7. package/dist/{mixedbread-d8e8wgqx.d.ts → mixedbread-CA3Xv15h.d.ts} +2 -2
  8. package/dist/search/algolia.d.ts +1 -1
  9. package/dist/search/client/algolia.d.ts +1 -1
  10. package/dist/search/client/docs-search.d.ts +1 -1
  11. package/dist/search/client/fetch.d.ts +1 -1
  12. package/dist/search/client/flexsearch-static.d.ts +1 -1
  13. package/dist/search/client/meilisearch.d.ts +1 -1
  14. package/dist/search/client/mixedbread.d.ts +2 -2
  15. package/dist/search/client/orama-cloud-legacy.d.ts +1 -1
  16. package/dist/search/client/orama-cloud.d.ts +1 -1
  17. package/dist/search/client/orama-static.d.ts +1 -1
  18. package/dist/search/client.d.ts +1 -1
  19. package/dist/search/flexsearch.d.ts +2 -2
  20. package/dist/search/meilisearch.d.ts +1 -1
  21. package/dist/search/mixedbread.d.ts +2 -2
  22. package/dist/search/orama-cloud.d.ts +1 -1
  23. package/dist/search/server.d.ts +1 -1
  24. package/dist/{server-BJlZvi0B.d.ts → server-D3xLyaLr.d.ts} +1 -1
  25. package/dist/source/dynamic.d.ts +1 -1
  26. package/dist/source/index.d.ts +1 -1
  27. package/dist/source/llms.d.ts +1 -1
  28. package/dist/source/llms.js +83 -47
  29. package/dist/source/plugins/lucide-icons.d.ts +1 -1
  30. package/dist/source/plugins/slugs.d.ts +1 -1
  31. package/dist/source/plugins/status-badges.d.ts +1 -1
  32. package/package.json +1 -1
@@ -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-DqVvRMMI.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-CQ_t21WZ.js";
4
- import "./mixedbread-d8e8wgqx.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";
@@ -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-DqVvRMMI.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>;
@@ -561,6 +561,16 @@ interface LLMsConfig<Page = unknown> {
561
561
  * The pages in `full()` and the files, every page by default.
562
562
  */
563
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
+ };
564
574
  }
565
575
  interface LLMs<IndexOutput extends Awaitable<string> = Awaitable<string>> {
566
576
  /**
@@ -586,9 +596,10 @@ interface LLMsWithPages<Page, IndexOutput extends Awaitable<string> = Awaitable<
586
596
  /**
587
597
  * The paths of the files for agents, for static output:
588
598
  *
589
- * - `/llms.txt` and `/llms-full.txt`: every page, linked to its `.md` file, and the `llms-full.txt` of directories.
590
- * - `<dir>/llms-full.txt`: the pages under a URL directory with two or more pages, like `/docs/guide`.
599
+ * - `/llms.txt`: the index, with a link to the `.md` file of each page.
600
+ * - `/llms-full.txt`: every page.
591
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`.
592
603
  *
593
604
  * @param lang - only the pages of a language, required when URLs don't have the locale (`hideLocale: 'always'`)
594
605
  */
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as SearchServer } from "./server-BJlZvi0B.js";
2
- import { D as LoaderOutput, T as LoaderConfig, r as LLMsWithPages } from "./index-DqVvRMMI.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
  /**
@@ -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-DqVvRMMI.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-BJlZvi0B.js";
3
- import { t as DocumentRecord } from "./meilisearch-BngEnZgG.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
  /**
@@ -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-CQ_t21WZ.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-Ca0pBjkk.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-Ca0pBjkk.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-Ca0pBjkk.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-Ca0pBjkk.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-Ca0pBjkk.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-Ca0pBjkk.js";
2
- import { n as SearchMetadata } from "../../mixedbread-d8e8wgqx.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-Ca0pBjkk.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-Ca0pBjkk.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-Ca0pBjkk.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 };
@@ -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-Ca0pBjkk.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-BJlZvi0B.js";
2
- import { D as LoaderOutput, T as LoaderConfig } from "../index-DqVvRMMI.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-BngEnZgG.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-BngEnZgG.js";
2
- import { a as sync, i as createMixedbreadSearchAPI, n as SearchMetadata, r as SyncOptions, t as MixedbreadSearchOptions } from "../mixedbread-d8e8wgqx.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,6 +1,6 @@
1
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-DqVvRMMI.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-BJlZvi0B.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-DqVvRMMI.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";
@@ -1,2 +1,2 @@
1
- import { b as DynamicLoaderConfig, x as dynamicLoader, y as DynamicLoader } from "../index-DqVvRMMI.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-DqVvRMMI.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-DqVvRMMI.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 = " ", filter = () => true } = 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") {
@@ -40,8 +40,11 @@ function llms(input, config = {}) {
40
40
  return formatListItem(formatMarkdownLink(renderName(node, ctx), config.renderUrl?.(node, ctx) ?? node.url), renderDescription(node, ctx), indent);
41
41
  }
42
42
  case "folder": {
43
- const out = [];
44
- 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];
45
48
  if (node.index) out.push(formatNode(node.index, indent + 1, ctx));
46
49
  for (const child of node.children) out.push(formatNode(child, indent + 1, ctx));
47
50
  return out.join("\n");
@@ -59,14 +62,27 @@ function llms(input, config = {}) {
59
62
  }));
60
63
  return out.join("\n\n");
61
64
  }
62
- const pageTree = loader.getPageTree(lang);
63
- const out = [];
64
- out.push(`# ${renderName(pageTree, ctx)}`, "");
65
- 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);
66
71
  if (description) out.push(`> ${description}`, "");
67
- 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));
68
75
  return out.join("\n");
69
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
+ }
70
86
  function renderPage(page) {
71
87
  if (!config.renderPage) throw new Error("`renderPage` is required by `page()` and `full()`, see llms() options.");
72
88
  return config.renderPage(page);
@@ -75,40 +91,73 @@ function llms(input, config = {}) {
75
91
  return (await Promise.all(pages.map(renderPage))).join("\n\n");
76
92
  }
77
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
+ }
78
137
  function withLoader(render) {
79
138
  if (typeof input === "function") return Promise.resolve(input()).then(render);
80
139
  return render(input);
81
140
  }
82
141
  async function renderFile(loader, path, lang) {
83
- if (path === "/llms.txt") {
84
- let text = formatIndex({
85
- loader,
86
- lang,
87
- markdown: true
88
- });
89
- const dirs = sections(getPages(loader, lang));
90
- if (dirs.size > 0) text += "\n\n## Sections\n";
91
- for (const dir of dirs.keys()) {
92
- const item = {
93
- type: "page",
94
- name: dir,
95
- url: `${dir}/llms-full.txt`
96
- };
97
- text += `\n- ${formatMarkdownLink(dir, config.renderUrl?.(item, { lang }) ?? item.url)}`;
98
- }
99
- return text;
100
- }
142
+ if (path === "/llms.txt") return formatIndex({
143
+ loader,
144
+ lang,
145
+ markdown: true
146
+ });
101
147
  if (path === "/llms-full.txt") return renderPages(getPages(loader, lang));
102
- if (path.endsWith("/llms-full.txt")) {
103
- const dirPages = sections(getPages(loader, lang)).get(path.slice(0, -14));
104
- return dirPages && renderPages(dirPages);
105
- }
106
148
  if (path.endsWith(".md")) {
107
149
  let url = path.slice(0, -3).replace(/(.)\/$/, "$1");
108
150
  if (url === "/index") url = "/";
109
151
  const page = loader.getPageByUrl(url, lang) ?? loader.getPageByUrl(`${url}/`, lang);
110
152
  if (page && filter(page)) return renderPage(page);
153
+ return;
111
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`);
112
161
  }
113
162
  return {
114
163
  index: (lang) => withLoader((loader) => formatIndex({
@@ -130,7 +179,10 @@ function llms(input, config = {}) {
130
179
  const pages = getPages(loader, lang);
131
180
  const out = /* @__PURE__ */ new Set(["/llms.txt", "/llms-full.txt"]);
132
181
  for (const page of pages) out.add(markdownPath(page.url));
133
- for (const dir of sections(pages).keys()) out.add(`${dir}/llms-full.txt`);
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
+ }
134
186
  return Array.from(out);
135
187
  });
136
188
  },
@@ -145,22 +197,6 @@ function llms(input, config = {}) {
145
197
  }
146
198
  };
147
199
  }
148
- /** the URL directories with two or more pages, and their pages */
149
- function sections(pages) {
150
- const dirs = /* @__PURE__ */ new Map();
151
- for (const page of pages) {
152
- const url = page.url.replace(/\/$/, "");
153
- if (!url.startsWith("/")) continue;
154
- for (let end = url.length; end > 0; end = url.lastIndexOf("/", end - 1)) {
155
- const dir = url.slice(0, end);
156
- const list = dirs.get(dir);
157
- if (list) list.push(page);
158
- else dirs.set(dir, [page]);
159
- }
160
- }
161
- for (const [dir, list] of dirs) if (list.length < 2) dirs.delete(dir);
162
- return dirs;
163
- }
164
200
  /** the path of the `.md` file of a page: `<page>.md`, `/index.md` for `/` */
165
201
  function markdownPath(url) {
166
202
  return url === "/" ? "/index.md" : `${url.replace(/\/$/, "")}.md`;
@@ -1,4 +1,4 @@
1
- import { O as LoaderPlugin } from "../../index-DqVvRMMI.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-DqVvRMMI.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 };
@@ -1,4 +1,4 @@
1
- import { O as LoaderPlugin } from "../../index-DqVvRMMI.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.1",
3
+ "version": "16.19.2",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Docs",