fumadocs-core 15.2.10 → 15.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { R as Root, N as Node } from './page-tree-BG3wP0gU.js';
2
+ import { R as Root, N as Node } from './page-tree-bSt6K__E.js';
3
3
 
4
4
  interface BreadcrumbItem {
5
5
  name: ReactNode;
@@ -19,7 +19,7 @@ function getBreadcrumbItemsFromPath(tree, path, options) {
19
19
  const { includePage = true, includeSeparator = false, includeRoot } = options;
20
20
  let items = [];
21
21
  path.forEach((item, i) => {
22
- if (item.type === "separator" && includeSeparator) {
22
+ if (item.type === "separator" && item.name && includeSeparator) {
23
23
  items.push({
24
24
  name: item.name
25
25
  });
@@ -24,7 +24,7 @@ interface Item {
24
24
  interface Separator {
25
25
  $id?: string;
26
26
  type: 'separator';
27
- name: ReactNode;
27
+ name?: ReactNode;
28
28
  icon?: ReactElement;
29
29
  }
30
30
  interface Folder {
@@ -7,7 +7,7 @@ import 'mdast';
7
7
  import 'unified';
8
8
  import 'mdast-util-mdx-jsx';
9
9
  import 'react';
10
- import '../page-tree-BG3wP0gU.js';
10
+ import '../page-tree-bSt6K__E.js';
11
11
 
12
12
  type AdvancedDocument = TypedDocument<Orama<typeof advancedSchema>>;
13
13
  declare const advancedSchema: {
@@ -43,10 +43,15 @@ type WithLocale<T> = T & {
43
43
  };
44
44
  declare function createI18nSearchAPI<T extends 'simple' | 'advanced'>(type: T, options: T extends 'simple' ? I18nSimpleOptions : I18nAdvancedOptions): SearchAPI;
45
45
 
46
- type Options = Omit<AdvancedOptions, 'language' | 'indexes'> & {
46
+ interface Options<Page = unknown> extends Omit<AdvancedOptions, 'indexes'> {
47
47
  localeMap?: LocaleMap<Partial<AdvancedOptions>>;
48
- };
49
- declare function createFromSource<S extends LoaderOutput<LoaderConfig>>(source: S, pageToIndexFn?: (page: InferPageType<S>) => AdvancedIndex, options?: Options): SearchAPI;
48
+ buildIndex?: (page: Page) => AdvancedIndex;
49
+ }
50
+ declare function createFromSource<S extends LoaderOutput<LoaderConfig>>(source: S, options?: Options<InferPageType<S>>): SearchAPI;
51
+ /**
52
+ * @deprecated Use `createFromSource(source, options)` instead.
53
+ */
54
+ declare function createFromSource<S extends LoaderOutput<LoaderConfig>>(source: S, pageToIndexFn?: (page: InferPageType<S>) => AdvancedIndex, options?: Omit<Options, 'buildIndex'>): SearchAPI;
50
55
 
51
56
  type SearchType = 'simple' | 'advanced';
52
57
  type ExportedData = (RawData & {
@@ -157,7 +157,13 @@ function pageToIndex(page) {
157
157
  structuredData
158
158
  };
159
159
  }
160
- function createFromSource(source, pageToIndexFn = pageToIndex, options = {}) {
160
+ function createFromSource(source, _buildIndexOrOptions = pageToIndex, _options) {
161
+ const options = {
162
+ ...typeof _buildIndexOrOptions === "function" ? {
163
+ buildIndex: _buildIndexOrOptions
164
+ } : _buildIndexOrOptions,
165
+ ..._options
166
+ };
161
167
  if (source._i18n) {
162
168
  return createI18nSearchAPI("advanced", {
163
169
  ...options,
@@ -165,7 +171,7 @@ function createFromSource(source, pageToIndexFn = pageToIndex, options = {}) {
165
171
  indexes: source.getLanguages().flatMap((entry) => {
166
172
  return entry.pages.map((page) => {
167
173
  return {
168
- ...pageToIndexFn(page),
174
+ ...(options.buildIndex ?? pageToIndex)(page),
169
175
  locale: entry.language
170
176
  };
171
177
  });
@@ -175,7 +181,7 @@ function createFromSource(source, pageToIndexFn = pageToIndex, options = {}) {
175
181
  return createSearchAPI("advanced", {
176
182
  ...options,
177
183
  indexes: source.getPages().map((page) => {
178
- return pageToIndexFn(page);
184
+ return (options.buildIndex ?? pageToIndex)(page);
179
185
  })
180
186
  });
181
187
  }
@@ -1,6 +1,6 @@
1
1
  export { a as TOCItemType, T as TableOfContents, g as getTableOfContents } from '../get-toc-Cr2URuiP.js';
2
- import { N as Node, I as Item, R as Root, F as Folder } from '../page-tree-BG3wP0gU.js';
3
- export { p as PageTree } from '../page-tree-BG3wP0gU.js';
2
+ import { N as Node, I as Item, R as Root, F as Folder } from '../page-tree-bSt6K__E.js';
3
+ export { p as PageTree } from '../page-tree-bSt6K__E.js';
4
4
  export { S as SortedResult } from '../types-Ch8gnVgO.js';
5
5
  import { Metadata } from 'next';
6
6
  import { NextRequest } from 'next/server';
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { I as I18nConfig } from '../config-inq6kP6y.js';
3
- import { R as Root, I as Item, F as Folder$1, S as Separator } from '../page-tree-BG3wP0gU.js';
3
+ import { R as Root, I as Item, F as Folder$1, S as Separator } from '../page-tree-bSt6K__E.js';
4
4
 
5
5
  interface FileInfo {
6
6
  /**
@@ -10,7 +10,7 @@ import {
10
10
  // src/source/page-tree-builder.ts
11
11
  var group = /^\((?<name>.+)\)$/;
12
12
  var link = /^(?:\[(?<icon>[^\]]+)])?\[(?<name>[^\]]+)]\((?<url>[^)]+)\)$/;
13
- var separator = /^---(?:\[(?<icon>[^\]]+)])?(?<name>.+)---$/;
13
+ var separator = /^---(?:\[(?<icon>[^\]]+)])?(?<name>.+)---|^---$/;
14
14
  var rest = "...";
15
15
  var restReversed = "z...a";
16
16
  var extractPrefix = "...";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.2.10",
3
+ "version": "15.2.12",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -97,19 +97,19 @@
97
97
  "@algolia/client-search": "4.24.0",
98
98
  "@mdx-js/mdx": "^3.1.0",
99
99
  "@oramacloud/client": "^2.1.4",
100
- "@tanstack/react-router": "^1.116.0",
100
+ "@tanstack/react-router": "^1.117.1",
101
101
  "@types/estree-jsx": "^1.0.5",
102
102
  "@types/hast": "^3.0.4",
103
103
  "@types/mdast": "^4.0.3",
104
104
  "@types/negotiator": "^0.6.3",
105
- "@types/node": "22.14.1",
105
+ "@types/node": "22.15.2",
106
106
  "@types/react": "^19.1.2",
107
107
  "@types/react-dom": "^19.1.2",
108
108
  "algoliasearch": "4.24.0",
109
109
  "mdast-util-mdx-jsx": "^3.2.0",
110
110
  "mdast-util-mdxjs-esm": "^2.0.1",
111
111
  "next": "^15.3.1",
112
- "react-router": "^7.5.1",
112
+ "react-router": "^7.5.2",
113
113
  "remark-mdx": "^3.1.0",
114
114
  "remark-rehype": "^11.1.2",
115
115
  "typescript": "^5.8.3",