fumadocs-core 15.2.11 → 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.
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "15.2.11",
3
+ "version": "15.2.12",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -115,8 +115,8 @@
115
115
  "typescript": "^5.8.3",
116
116
  "unified": "^11.0.5",
117
117
  "vfile": "^6.0.3",
118
- "tsconfig": "0.0.0",
119
- "eslint-config-custom": "0.0.0"
118
+ "eslint-config-custom": "0.0.0",
119
+ "tsconfig": "0.0.0"
120
120
  },
121
121
  "peerDependencies": {
122
122
  "@oramacloud/client": "1.x.x || 2.x.x",