fumadocs-core 15.8.5 → 16.0.1

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 (46) hide show
  1. package/dist/breadcrumb.d.ts +1 -1
  2. package/dist/breadcrumb.js +3 -3
  3. package/dist/{builder-5BHIAfCi.d.ts → builder-feW_xVjc.d.ts} +12 -99
  4. package/dist/{chunk-2IYQ7QMS.js → chunk-IZPLHEX4.js} +22 -6
  5. package/dist/{chunk-HN2NUUD2.js → chunk-XN2LKXFZ.js} +16 -27
  6. package/dist/{chunk-LMRZFODA.js → chunk-XZSI7AHE.js} +0 -16
  7. package/dist/content/github.js +39 -3
  8. package/dist/content/toc.d.ts +1 -0
  9. package/dist/content/toc.js +16 -3
  10. package/dist/{definitions-Q95-psoo.d.ts → definitions-BRsJlZ6m.d.ts} +1 -10
  11. package/dist/hide-if-empty.js +1 -19
  12. package/dist/highlight/client.d.ts +7 -13
  13. package/dist/highlight/client.js +5 -16
  14. package/dist/highlight/index.d.ts +13 -7
  15. package/dist/highlight/index.js +3 -1
  16. package/dist/i18n/index.js +5 -3
  17. package/dist/mdx-plugins/index.d.ts +6 -6
  18. package/dist/mdx-plugins/index.js +10 -13
  19. package/dist/{orama-cloud-74FM25SB.js → orama-cloud-WEGQE5A6.js} +8 -5
  20. package/dist/page-tree/index.d.ts +3 -3
  21. package/dist/page-tree/index.js +1 -1
  22. package/dist/search/algolia.d.ts +0 -6
  23. package/dist/search/algolia.js +1 -1
  24. package/dist/search/client.d.ts +4 -24
  25. package/dist/search/client.js +11 -18
  26. package/dist/search/orama-cloud.d.ts +3 -3
  27. package/dist/search/orama-cloud.js +16 -9
  28. package/dist/search/server.d.ts +2 -10
  29. package/dist/search/server.js +7 -12
  30. package/dist/source/index.d.ts +35 -5
  31. package/dist/source/index.js +15 -78
  32. package/dist/source/plugins/lucide-icons.d.ts +2 -2
  33. package/dist/toc.d.ts +4 -3
  34. package/dist/toc.js +1 -1
  35. package/dist/utils/use-media-query.js +19 -3
  36. package/package.json +21 -31
  37. package/dist/chunk-CX7IQ5Z6.js +0 -21
  38. package/dist/chunk-EP5LHGDZ.js +0 -22
  39. package/dist/chunk-HSBNG7QC.js +0 -42
  40. package/dist/chunk-HUTQC33E.js +0 -8
  41. package/dist/i18n/legacy.d.ts +0 -15
  42. package/dist/i18n/legacy.js +0 -19
  43. package/dist/server/index.d.ts +0 -66
  44. package/dist/server/index.js +0 -84
  45. package/dist/sidebar.d.ts +0 -33
  46. package/dist/sidebar.js +0 -79
@@ -1,11 +1,11 @@
1
+ import {
2
+ defaultThemes,
3
+ getHighlighter
4
+ } from "../chunk-XN2LKXFZ.js";
1
5
  import {
2
6
  flattenNode,
3
7
  remarkHeading
4
8
  } from "../chunk-QMATWJ5F.js";
5
- import {
6
- defaultThemes,
7
- getHighlighter
8
- } from "../chunk-HN2NUUD2.js";
9
9
  import "../chunk-U67V476Y.js";
10
10
 
11
11
  // src/mdx-plugins/index.ts
@@ -254,7 +254,7 @@ var rehypeCodeDefaultOptions = {
254
254
  themes: defaultThemes,
255
255
  defaultColor: false,
256
256
  defaultLanguage: "plaintext",
257
- experimentalJSEngine: false,
257
+ engine: "js",
258
258
  transformers: [
259
259
  transformerNotationHighlight({
260
260
  matchAlgorithm: "v3"
@@ -310,14 +310,11 @@ function rehypeCode(_options = {}) {
310
310
  if (options.tab !== false) {
311
311
  transformers.push(transformerTab());
312
312
  }
313
- const highlighter = getHighlighter(
314
- options.experimentalJSEngine ? "js" : "oniguruma",
315
- {
316
- themes: "themes" in options ? Object.values(options.themes).filter(Boolean) : [options.theme],
317
- langs: options.langs ?? (options.lazy ? ["ts", "tsx"] : Object.keys(bundledLanguages)),
318
- langAlias: options.langAlias
319
- }
320
- );
313
+ const highlighter = getHighlighter(options.engine ?? "js", {
314
+ themes: "themes" in options ? Object.values(options.themes).filter(Boolean) : [options.theme],
315
+ langs: options.langs ?? (options.lazy ? ["ts", "tsx"] : Object.keys(bundledLanguages)),
316
+ langAlias: options.langAlias
317
+ });
321
318
  const transformer = highlighter.then(
322
319
  (loaded) => rehypeShikiFromHighlighter(loaded, {
323
320
  ...options,
@@ -10,16 +10,17 @@ import "./chunk-U67V476Y.js";
10
10
  async function searchDocs(query, options) {
11
11
  const highlighter = createContentHighlighter(query);
12
12
  const list = [];
13
- const { index = "default", client, params: extraParams = {}, tag } = options;
13
+ const { index = "default", client, params: extraParams, tag } = options;
14
14
  if (index === "crawler") {
15
15
  const result2 = await client.search({
16
+ datasources: [],
16
17
  ...extraParams,
17
18
  term: query,
18
19
  where: {
19
20
  category: tag ? {
20
21
  eq: tag.slice(0, 1).toUpperCase() + tag.slice(1)
21
22
  } : void 0,
22
- ...extraParams.where
23
+ ...extraParams?.where
23
24
  },
24
25
  limit: 10
25
26
  });
@@ -46,16 +47,18 @@ async function searchDocs(query, options) {
46
47
  return list;
47
48
  }
48
49
  const params = {
50
+ datasources: [],
49
51
  ...extraParams,
50
52
  term: query,
51
53
  where: removeUndefined({
52
54
  tag,
53
- ...extraParams.where
55
+ ...extraParams?.where
54
56
  }),
55
57
  groupBy: {
58
+ // TODO: this was causing error on number of group variants
56
59
  properties: ["page_id"],
57
- maxResult: 7,
58
- ...extraParams.groupBy
60
+ max_results: 7,
61
+ ...extraParams?.groupBy
59
62
  }
60
63
  };
61
64
  const result = await client.search(params);
@@ -1,5 +1,5 @@
1
- import { N as Node, I as Item, R as Root, F as Folder } from '../definitions-Q95-psoo.js';
2
- export { S as Separator } from '../definitions-Q95-psoo.js';
1
+ import { N as Node, I as Item, R as Root, F as Folder } from '../definitions-BRsJlZ6m.js';
2
+ export { S as Separator } from '../definitions-BRsJlZ6m.js';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -19,7 +19,7 @@ declare function getPageTreeRoots(pageTree: Root | Folder): (Root | Folder)[];
19
19
  /**
20
20
  * Get other page tree nodes that lives under the same parent
21
21
  */
22
- declare function getPageTreePeers(tree: Root, url: string): Item[];
22
+ declare function getPageTreePeers(treeOrTrees: Root | Record<string, Root>, url: string): Item[];
23
23
  /**
24
24
  * Search the path of a node in the tree matched by the matcher.
25
25
  *
@@ -4,7 +4,7 @@ import {
4
4
  flattenTree,
5
5
  getPageTreePeers,
6
6
  getPageTreeRoots
7
- } from "../chunk-2IYQ7QMS.js";
7
+ } from "../chunk-IZPLHEX4.js";
8
8
  import "../chunk-U67V476Y.js";
9
9
  export {
10
10
  findNeighbour,
@@ -27,12 +27,6 @@ interface DocumentRecord {
27
27
  extra_data?: object;
28
28
  }
29
29
  interface SyncOptions {
30
- /**
31
- * Index Name for documents.
32
- *
33
- * @deprecated Use `indexName` instead
34
- */
35
- document?: string;
36
30
  /**
37
31
  * Index Name for documents.
38
32
  */
@@ -2,7 +2,7 @@ import "../chunk-U67V476Y.js";
2
2
 
3
3
  // src/search/algolia.ts
4
4
  async function sync(client, options) {
5
- const { document = "document", indexName = document, documents } = options;
5
+ const { indexName = "document", documents } = options;
6
6
  await setIndexSettings(client, indexName);
7
7
  await updateDocuments(client, indexName, documents);
8
8
  }
@@ -2,7 +2,7 @@ import { AnyOrama } from '@orama/orama';
2
2
  import '../remark-structure-DkCXCzpD.js';
3
3
  import { BaseIndex } from './algolia.js';
4
4
  import { LiteClient, SearchResponse } from 'algoliasearch/lite';
5
- import { OramaClient, ClientSearchParams } from '@oramacloud/client';
5
+ import { OramaCloud, OramaCloudSearchParams } from '@orama/core';
6
6
  import Mixedbread from '@mixedbread/sdk';
7
7
  import { SortedResult } from './index.js';
8
8
  import 'mdast';
@@ -60,14 +60,14 @@ interface AlgoliaOptions {
60
60
  }
61
61
 
62
62
  interface OramaCloudOptions {
63
- client: OramaClient;
63
+ client: OramaCloud;
64
64
  /**
65
65
  * The type of your index.
66
66
  *
67
67
  * You can set it to `crawler` if you use crawler instead of the JSON index with schema provided by Fumadocs
68
68
  */
69
69
  index?: 'default' | 'crawler';
70
- params?: ClientSearchParams;
70
+ params?: Partial<OramaCloudSearchParams>;
71
71
  /**
72
72
  * Filter results with specific tag.
73
73
  */
@@ -135,26 +135,6 @@ declare function useDocsSearch(clientOptions: Client & {
135
135
  * @defaultValue false
136
136
  */
137
137
  allowEmpty?: boolean;
138
- },
139
- /**
140
- * @deprecated pass to `client` object instead
141
- */
142
- _locale?: string,
143
- /**
144
- * @deprecated pass to `client` object instead
145
- */
146
- _tag?: string,
147
- /**
148
- * @deprecated pass to `client` object instead
149
- */
150
- _delayMs?: number,
151
- /**
152
- * @deprecated pass to `client` object instead
153
- */
154
- _allowEmpty?: boolean,
155
- /**
156
- * @deprecated No longer used
157
- */
158
- _key?: string): UseDocsSearch;
138
+ }): UseDocsSearch;
159
139
 
160
140
  export { type AlgoliaOptions, type Client, type FetchOptions, type OramaCloudOptions, type StaticOptions, useDocsSearch };
@@ -4,21 +4,20 @@ import {
4
4
  import "../chunk-U67V476Y.js";
5
5
 
6
6
  // src/search/client.ts
7
- import { useRef as useRef2, useState as useState2 } from "react";
7
+ import { useRef, useState as useState2 } from "react";
8
8
 
9
9
  // src/utils/use-debounce.ts
10
- import { useRef, useState } from "react";
10
+ import { useEffect, useState } from "react";
11
11
  function useDebounce(value, delayMs = 1e3) {
12
12
  const [debouncedValue, setDebouncedValue] = useState(value);
13
- const timer = useRef(void 0);
14
- if (delayMs === 0) return value;
15
- if (value !== debouncedValue && timer.current?.value !== value) {
16
- if (timer.current) clearTimeout(timer.current.handler);
13
+ useEffect(() => {
14
+ if (delayMs === 0) return;
17
15
  const handler = window.setTimeout(() => {
18
16
  setDebouncedValue(value);
19
17
  }, delayMs);
20
- timer.current = { value, handler };
21
- }
18
+ return () => clearTimeout(handler);
19
+ }, [delayMs, value]);
20
+ if (delayMs === 0) return value;
22
21
  return debouncedValue;
23
22
  }
24
23
 
@@ -36,20 +35,14 @@ function isDifferentDeep(a, b) {
36
35
  }
37
36
  return a !== b;
38
37
  }
39
- function useDocsSearch(clientOptions, _locale, _tag, _delayMs = 100, _allowEmpty = false, _key) {
40
- const {
41
- delayMs = _delayMs ?? 100,
42
- allowEmpty = _allowEmpty ?? false,
43
- ...client
44
- } = clientOptions;
45
- client.tag ??= _tag;
46
- client.locale ??= _locale;
38
+ function useDocsSearch(clientOptions) {
39
+ const { delayMs = 100, allowEmpty = false, ...client } = clientOptions;
47
40
  const [search, setSearch] = useState2("");
48
41
  const [results, setResults] = useState2("empty");
49
42
  const [error, setError] = useState2();
50
43
  const [isLoading, setIsLoading] = useState2(false);
51
44
  const debouncedValue = useDebounce(search, delayMs);
52
- const onStart = useRef2(void 0);
45
+ const onStart = useRef(void 0);
53
46
  useOnChange(
54
47
  [client, debouncedValue],
55
48
  () => {
@@ -73,7 +66,7 @@ function useDocsSearch(clientOptions, _locale, _tag, _delayMs = 100, _allowEmpty
73
66
  return searchDocs(debouncedValue, client);
74
67
  }
75
68
  if (client.type === "orama-cloud") {
76
- const { searchDocs } = await import("../orama-cloud-74FM25SB.js");
69
+ const { searchDocs } = await import("../orama-cloud-WEGQE5A6.js");
77
70
  return searchDocs(debouncedValue, client);
78
71
  }
79
72
  if (client.type === "static") {
@@ -1,6 +1,6 @@
1
- import { CloudManager } from '@oramacloud/client';
2
1
  import { S as StructuredData } from '../remark-structure-DkCXCzpD.js';
3
2
  import '../remark-code-tab-DmyIyi6m.js';
3
+ import { OramaCloud } from '@orama/core';
4
4
  import 'mdast';
5
5
  import 'unified';
6
6
  import 'mdast-util-mdx-jsx';
@@ -72,7 +72,7 @@ interface OramaIndex {
72
72
  section_id?: string;
73
73
  content: string;
74
74
  }
75
- declare function sync(cloudManager: CloudManager, options: SyncOptions): Promise<void>;
76
- declare function syncI18n(cloudManager: CloudManager, options: I18nSyncOptions): Promise<void>;
75
+ declare function sync(orama: OramaCloud, options: SyncOptions): Promise<void>;
76
+ declare function syncI18n(orama: OramaCloud, options: I18nSyncOptions): Promise<void>;
77
77
 
78
78
  export { type I18nSyncOptions, type OramaDocument, type OramaIndex, type SyncOptions, sync, syncI18n };
@@ -1,18 +1,24 @@
1
1
  import "../chunk-U67V476Y.js";
2
2
 
3
3
  // src/search/orama-cloud.ts
4
- async function sync(cloudManager, options) {
4
+ async function sync(orama, options) {
5
5
  const { autoDeploy = true } = options;
6
- const index = cloudManager.index(options.index);
7
- await index.snapshot(options.documents.flatMap(toIndex));
8
- if (autoDeploy) await index.deploy();
6
+ const index = orama.index.set(options.index);
7
+ await index.transaction.open();
8
+ await index.transaction.insertDocuments(
9
+ options.documents.flatMap(toIndex)
10
+ );
11
+ if (autoDeploy) await index.transaction.commit();
9
12
  }
10
- async function syncI18n(cloudManager, options) {
11
- const { autoDeploy = true } = options;
13
+ async function syncI18n(orama, options) {
14
+ const { autoDeploy = true, indexes } = options;
12
15
  const tasks = options.documents.map(async (document) => {
13
- const index = cloudManager.index(options.indexes[document.locale]);
14
- await index.snapshot(document.items.flatMap(toIndex));
15
- if (autoDeploy) await index.deploy();
16
+ const index = orama.index.set(indexes[document.locale]);
17
+ await index.transaction.open();
18
+ await index.transaction.insertDocuments(
19
+ document.items.flatMap(toIndex)
20
+ );
21
+ if (autoDeploy) await index.transaction.commit();
16
22
  });
17
23
  await Promise.all(tasks);
18
24
  }
@@ -25,6 +31,7 @@ function toIndex(page) {
25
31
  id: `${page.id}-${(id++).toString()}`,
26
32
  title: page.title,
27
33
  url: page.url,
34
+ // TODO: explicit declare enums
28
35
  page_id: page.id,
29
36
  tag: page.tag,
30
37
  section,
@@ -3,12 +3,12 @@ import { S as StructuredData } from '../remark-structure-DkCXCzpD.js';
3
3
  import { SortedResult } from './index.js';
4
4
  export { HighlightedText, ReactSortedResult, createContentHighlighter } from './index.js';
5
5
  import { I18nConfig } from '../i18n/index.js';
6
- import { L as LoaderOutput, a as LoaderConfig, I as InferPageType } from '../builder-5BHIAfCi.js';
6
+ import { k as LoaderOutput, f as LoaderConfig, I as InferPageType } from '../builder-feW_xVjc.js';
7
7
  import 'mdast';
8
8
  import 'unified';
9
9
  import 'mdast-util-mdx-jsx';
10
10
  import 'react';
11
- import '../definitions-Q95-psoo.js';
11
+ import '../definitions-BRsJlZ6m.js';
12
12
 
13
13
  type SimpleDocument = TypedDocument<Orama<typeof simpleSchema>>;
14
14
  declare const simpleSchema: {
@@ -38,10 +38,6 @@ interface Options<S extends LoaderOutput<LoaderConfig>> extends Omit<AdvancedOpt
38
38
  buildIndex?: (page: InferPageType<S>) => Awaitable<AdvancedIndex>;
39
39
  }
40
40
  declare function createFromSource<S extends LoaderOutput<LoaderConfig>>(source: S, options?: Options<S>): SearchAPI;
41
- /**
42
- * @deprecated Use `createFromSource(source, options)` instead.
43
- */
44
- declare function createFromSource<S extends LoaderOutput<LoaderConfig>>(source: S, pageToIndexFn?: (page: InferPageType<S>) => Awaitable<AdvancedIndex>, options?: Omit<Options<S>, 'buildIndex'>): SearchAPI;
45
41
 
46
42
  type I18nOptions<O extends SimpleOptions | AdvancedOptions, Idx> = Omit<O, 'language' | 'indexes'> & {
47
43
  i18n: I18nConfig;
@@ -124,10 +120,6 @@ interface AdvancedIndex {
124
120
  id: string;
125
121
  title: string;
126
122
  description?: string;
127
- /**
128
- * @deprecated No longer used
129
- */
130
- keywords?: string;
131
123
  breadcrumbs?: string[];
132
124
  /**
133
125
  * Required if tag filter is enabled
@@ -3,16 +3,16 @@ import {
3
3
  searchSimple
4
4
  } from "../chunk-XOFXGHS4.js";
5
5
  import "../chunk-ZMWYLUDP.js";
6
- import {
7
- createContentHighlighter
8
- } from "../chunk-OTD7MV33.js";
9
6
  import {
10
7
  basename,
11
8
  extname
12
- } from "../chunk-LMRZFODA.js";
9
+ } from "../chunk-XZSI7AHE.js";
10
+ import {
11
+ createContentHighlighter
12
+ } from "../chunk-OTD7MV33.js";
13
13
  import {
14
14
  findPath
15
- } from "../chunk-2IYQ7QMS.js";
15
+ } from "../chunk-IZPLHEX4.js";
16
16
  import "../chunk-U67V476Y.js";
17
17
 
18
18
  // src/search/server.ts
@@ -201,13 +201,8 @@ function defaultBuildIndex(source) {
201
201
  };
202
202
  };
203
203
  }
204
- function createFromSource(source, _buildIndexOrOptions, _options) {
205
- const { buildIndex = defaultBuildIndex(source), ...options } = {
206
- ...typeof _buildIndexOrOptions === "function" ? {
207
- buildIndex: _buildIndexOrOptions
208
- } : _buildIndexOrOptions,
209
- ..._options
210
- };
204
+ function createFromSource(source, options = {}) {
205
+ const { buildIndex = defaultBuildIndex(source) } = options;
211
206
  if (source._i18n) {
212
207
  return createI18nSearchAPI("advanced", {
213
208
  ...options,
@@ -1,12 +1,42 @@
1
- import { F as FileInfo } from '../builder-5BHIAfCi.js';
2
- export { C as ContentStorage, f as FileSystem, v as InferMetaType, I as InferPageType, a as LoaderConfig, i as LoaderOptions, L as LoaderOutput, w as LoaderPlugin, l as Meta, r as MetaData, M as MetaFile, k as Page, s as PageData, g as PageFile, b as PageTreeBuilder, d as PageTreeBuilderContext, e as PageTreeOptions, P as PageTreeTransformer, p as PathUtils, R as ResolvedLoaderConfig, j as Source, S as SourceConfig, T as Transformer, U as UrlFn, u as VirtualFile, t as VirtualMeta, V as VirtualPage, _ as _ConfigUnion_, x as buildPlugins, m as createGetUrl, c as createPageTreeBuilder, n as loader, q as map, o as multiple, h as parseFilePath } from '../builder-5BHIAfCi.js';
3
- import '../definitions-Q95-psoo.js';
1
+ export { C as ContentStorage, F as FileSystem, t as InferMetaType, I as InferPageType, f as LoaderConfig, g as LoaderOptions, k as LoaderOutput, L as LoaderPlugin, j as Meta, p as MetaData, M as MetaFile, i as Page, q as PageData, e as PageFile, a as PageTreeBuilder, b as PageTreeBuilderContext, d as PageTreeOptions, P as PageTreeTransformer, R as ResolvedLoaderConfig, h as Source, S as SourceConfig, U as UrlFn, s as VirtualFile, r as VirtualMeta, V as VirtualPage, _ as _ConfigUnion_, u as buildPlugins, l as createGetUrl, c as createPageTreeBuilder, m as loader, o as map, n as multiple } from '../builder-feW_xVjc.js';
2
+ import '../definitions-BRsJlZ6m.js';
4
3
  import 'react';
5
4
  import '../i18n/index.js';
6
5
 
7
6
  /**
8
7
  * Convert file path into slugs, also encode non-ASCII characters, so they can work in pathname
9
8
  */
10
- declare function getSlugs(file: string | FileInfo): string[];
9
+ declare function getSlugs(file: string): string[];
11
10
 
12
- export { FileInfo, getSlugs };
11
+ declare function basename(path: string, ext?: string): string;
12
+ declare function extname(path: string): string;
13
+ declare function dirname(path: string): string;
14
+ /**
15
+ * Split path into segments, trailing/leading slashes are removed
16
+ */
17
+ declare function splitPath(path: string): string[];
18
+ /**
19
+ * Resolve paths, slashes within the path will be ignored
20
+ * @param paths - Paths to join
21
+ * @example
22
+ * ```
23
+ * ['a','b'] // 'a/b'
24
+ * ['/a'] // 'a'
25
+ * ['a', '/b'] // 'a/b'
26
+ * ['a', '../b/c'] // 'b/c'
27
+ * ```
28
+ */
29
+ declare function joinPath(...paths: string[]): string;
30
+ declare function slash(path: string): string;
31
+
32
+ declare const path_basename: typeof basename;
33
+ declare const path_dirname: typeof dirname;
34
+ declare const path_extname: typeof extname;
35
+ declare const path_joinPath: typeof joinPath;
36
+ declare const path_slash: typeof slash;
37
+ declare const path_splitPath: typeof splitPath;
38
+ declare namespace path {
39
+ export { path_basename as basename, path_dirname as dirname, path_extname as extname, path_joinPath as joinPath, path_slash as slash, path_splitPath as splitPath };
40
+ }
41
+
42
+ export { path as PathUtils, getSlugs };
@@ -1,16 +1,15 @@
1
- import {
2
- iconPlugin
3
- } from "../chunk-FAEPKD7U.js";
4
1
  import {
5
2
  basename,
6
3
  dirname,
7
4
  extname,
8
5
  joinPath,
9
- parseFilePath,
10
6
  path_exports,
11
7
  slash,
12
8
  splitPath
13
- } from "../chunk-LMRZFODA.js";
9
+ } from "../chunk-XZSI7AHE.js";
10
+ import {
11
+ iconPlugin
12
+ } from "../chunk-FAEPKD7U.js";
14
13
  import {
15
14
  normalizeUrl
16
15
  } from "../chunk-PFNP6PEB.js";
@@ -227,8 +226,14 @@ function build(id, ctx) {
227
226
  return root;
228
227
  }
229
228
  function createPageTreeBuilder(getUrl, plugins) {
230
- function getTransformers(generateFallback) {
229
+ function getTransformers({
230
+ generateFallback = true,
231
+ ...options
232
+ }) {
231
233
  const transformers = [];
234
+ if (options.transformers) {
235
+ transformers.push(...options.transformers);
236
+ }
232
237
  for (const plugin of plugins ?? []) {
233
238
  if (plugin.transformPageTree) transformers.push(plugin.transformPageTree);
234
239
  }
@@ -255,13 +260,12 @@ function createPageTreeBuilder(getUrl, plugins) {
255
260
  return this.buildI18n({ [key]: storage }, options)[key];
256
261
  },
257
262
  buildI18n(storages, options = {}) {
258
- const { id, generateFallback = true } = options;
259
- const transformers = getTransformers(generateFallback);
263
+ const transformers = getTransformers(options);
260
264
  const out = {};
261
265
  for (const [locale, storage] of Object.entries(storages)) {
262
266
  const resolve = createFlattenPathResolver(storage);
263
267
  const branch = locale.length === 0 ? "root" : locale;
264
- out[locale] = build(id ? `${id}-${branch}` : branch, {
268
+ out[locale] = build(options.id ? `${options.id}-${branch}` : branch, {
265
269
  transformers,
266
270
  builder: this,
267
271
  options,
@@ -455,7 +459,7 @@ function slugsPlugin(slugsFn) {
455
459
  indexFiles.add(path);
456
460
  continue;
457
461
  }
458
- file.slugs = slugsFn ? slugsFn(parseFilePath(path)) : getSlugs(path);
462
+ file.slugs = slugsFn ? slugsFn({ path }) : getSlugs(path);
459
463
  const key = file.slugs.join("/");
460
464
  if (taken.has(key)) throw new Error("Duplicated slugs");
461
465
  taken.add(key);
@@ -471,7 +475,6 @@ function slugsPlugin(slugsFn) {
471
475
  }
472
476
  var GroupRegex = /^\(.+\)$/;
473
477
  function getSlugs(file) {
474
- if (typeof file !== "string") return getSlugs(file.path);
475
478
  const dir = dirname(file);
476
479
  const name = basename(file, extname(file));
477
480
  const slugs = [];
@@ -486,64 +489,6 @@ function getSlugs(file) {
486
489
  return slugs;
487
490
  }
488
491
 
489
- // src/source/plugins/compat.ts
490
- function compatPlugin({
491
- pageTree,
492
- transformers
493
- }) {
494
- const plugins = [];
495
- if (pageTree) {
496
- const { attachFile, attachSeparator, attachFolder, transformers: transformers2 } = pageTree;
497
- for (const transformer of transformers2 ?? []) {
498
- plugins.push(fromPageTreeTransformer(transformer));
499
- }
500
- plugins.push(
501
- fromPageTreeTransformer({
502
- file(node, file) {
503
- if (!attachFile) return node;
504
- const content = file ? this.storage.read(file) : void 0;
505
- return attachFile(
506
- node,
507
- content?.format === "page" ? content : void 0
508
- );
509
- },
510
- folder(node, folderPath, metaPath) {
511
- if (!attachFolder) return node;
512
- const files = this.storage.readDir(folderPath) ?? [];
513
- const meta = metaPath ? this.storage.read(metaPath) : void 0;
514
- return attachFolder(
515
- node,
516
- {
517
- children: files.flatMap((file) => this.storage.read(file) ?? [])
518
- },
519
- meta?.format === "meta" ? meta : void 0
520
- );
521
- },
522
- separator(node) {
523
- if (!attachSeparator) return node;
524
- return attachSeparator(node);
525
- }
526
- })
527
- );
528
- }
529
- if (transformers) {
530
- for (const transformer of transformers) {
531
- plugins.push(fromStorageTransformer(transformer));
532
- }
533
- }
534
- return plugins;
535
- }
536
- function fromPageTreeTransformer(transformer) {
537
- return {
538
- transformPageTree: transformer
539
- };
540
- }
541
- function fromStorageTransformer(transformer) {
542
- return {
543
- transformStorage: transformer
544
- };
545
- }
546
-
547
492
  // src/source/loader.ts
548
493
  function indexPages(storages, getUrl) {
549
494
  const result = {
@@ -597,7 +542,6 @@ function resolveConfig(source, { slugs, icon, plugins = [], baseUrl, url, ...bas
597
542
  plugins: buildPlugins([
598
543
  slugsPlugin(slugs),
599
544
  icon && iconPlugin(icon),
600
- compatPlugin(base),
601
545
  ...plugins
602
546
  ])
603
547
  };
@@ -733,17 +677,11 @@ function fileToMeta(file) {
733
677
  return {
734
678
  path: file.path,
735
679
  absolutePath: file.absolutePath,
736
- get file() {
737
- return parseFilePath(this.path);
738
- },
739
680
  data: file.data
740
681
  };
741
682
  }
742
683
  function fileToPage(file, getUrl, locale) {
743
684
  return {
744
- get file() {
745
- return parseFilePath(this.path);
746
- },
747
685
  absolutePath: file.absolutePath,
748
686
  path: file.path,
749
687
  url: getUrl(file.slugs, locale),
@@ -793,6 +731,5 @@ export {
793
731
  getSlugs,
794
732
  loader,
795
733
  map,
796
- multiple,
797
- parseFilePath
734
+ multiple
798
735
  };
@@ -1,6 +1,6 @@
1
- import { w as LoaderPlugin } from '../../builder-5BHIAfCi.js';
1
+ import { L as LoaderPlugin } from '../../builder-feW_xVjc.js';
2
2
  import { icons } from 'lucide-react';
3
- import '../../definitions-Q95-psoo.js';
3
+ import '../../definitions-BRsJlZ6m.js';
4
4
  import 'react';
5
5
  import '../../i18n/index.js';
6
6
 
package/dist/toc.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, RefObject, AnchorHTMLAttributes } from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
 
4
5
  interface TOCItemType {
5
6
  title: ReactNode;
@@ -20,7 +21,7 @@ interface AnchorProviderProps {
20
21
  /**
21
22
  * Only accept one active item at most
22
23
  *
23
- * @defaultValue true
24
+ * @defaultValue false
24
25
  */
25
26
  single?: boolean;
26
27
  children?: ReactNode;
@@ -32,8 +33,8 @@ interface ScrollProviderProps {
32
33
  containerRef: RefObject<HTMLElement | null>;
33
34
  children?: ReactNode;
34
35
  }
35
- declare function ScrollProvider({ containerRef, children, }: ScrollProviderProps): React.ReactElement;
36
- declare function AnchorProvider({ toc, single, children, }: AnchorProviderProps): React.ReactElement;
36
+ declare function ScrollProvider({ containerRef, children, }: ScrollProviderProps): react_jsx_runtime.JSX.Element;
37
+ declare function AnchorProvider({ toc, single, children, }: AnchorProviderProps): react_jsx_runtime.JSX.Element;
37
38
  interface TOCItemProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
38
39
  href: string;
39
40
  onActiveChange?: (v: boolean) => void;
package/dist/toc.js CHANGED
@@ -88,7 +88,7 @@ function ScrollProvider({
88
88
  }
89
89
  function AnchorProvider({
90
90
  toc,
91
- single = true,
91
+ single = false,
92
92
  children
93
93
  }) {
94
94
  const headings = useMemo(() => {