fumadocs-core 14.6.8 → 14.7.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.
@@ -20,7 +20,7 @@ import {
20
20
  // src/mdx-plugins/rehype-code.ts
21
21
  import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
22
22
 
23
- // ../../node_modules/.pnpm/shiki-transformers@1.0.1_shiki@1.24.3/node_modules/shiki-transformers/dist/index.js
23
+ // ../../node_modules/.pnpm/shiki-transformers@1.0.1_shiki@1.26.1/node_modules/shiki-transformers/dist/index.js
24
24
  var matchers = [
25
25
  [/^(<!--)(.+)(-->)$/, false],
26
26
  [/^(\/\*)(.+)(\*\/)$/, false],
@@ -54,4 +54,4 @@ type Client = ({
54
54
  */
55
55
  declare function useDocsSearch(client: Client, locale?: string, tag?: string, delayMs?: number, allowEmpty?: boolean, key?: string): UseDocsSearch;
56
56
 
57
- export { type AlgoliaOptions, type FetchOptions, type OramaCloudOptions, type StaticOptions, useDocsSearch };
57
+ export { type AlgoliaOptions, type Client, type FetchOptions, type OramaCloudOptions, type StaticOptions, useDocsSearch };
@@ -208,9 +208,18 @@ var STEMMERS = {
208
208
  };
209
209
 
210
210
  // src/search/orama/create-i18n.ts
211
- function defaultLocaleMap(locale) {
212
- const map = STEMMERS;
213
- return Object.keys(map).find((lang) => map[lang] === locale) ?? locale;
211
+ async function getTokenizer(locale) {
212
+ const mandarin = ["cn", "zh"];
213
+ const language = Object.keys(STEMMERS).find((lang) => STEMMERS[lang] === locale) ?? locale;
214
+ if (mandarin.some((code) => locale === code || locale.startsWith(`${code}-`))) {
215
+ const { createTokenizer } = await import("@orama/tokenizers/mandarin");
216
+ return {
217
+ tokenizer: await createTokenizer()
218
+ };
219
+ }
220
+ return {
221
+ language
222
+ };
214
223
  }
215
224
  async function initSimple(options) {
216
225
  const map = /* @__PURE__ */ new Map();
@@ -220,7 +229,7 @@ async function initSimple(options) {
220
229
  const indexes = typeof options.indexes === "function" ? await options.indexes() : options.indexes;
221
230
  for (const locale of options.i18n.languages) {
222
231
  const localeIndexes = indexes.filter((index) => index.locale === locale);
223
- const searchLocale = options.localeMap?.[locale] ?? defaultLocaleMap(locale);
232
+ const searchLocale = options.localeMap?.[locale] ?? await getTokenizer(locale);
224
233
  map.set(
225
234
  locale,
226
235
  typeof searchLocale === "object" ? initSimpleSearch({
@@ -244,7 +253,7 @@ async function initAdvanced(options) {
244
253
  const indexes = typeof options.indexes === "function" ? await options.indexes() : options.indexes;
245
254
  for (const locale of options.i18n.languages) {
246
255
  const localeIndexes = indexes.filter((index) => index.locale === locale);
247
- const searchLocale = options.localeMap?.[locale] ?? defaultLocaleMap(locale);
256
+ const searchLocale = options.localeMap?.[locale] ?? await getTokenizer(locale);
248
257
  map.set(
249
258
  locale,
250
259
  typeof searchLocale === "object" ? initAdvancedSearch({
@@ -59,13 +59,11 @@ interface SourceConfig {
59
59
  }
60
60
  interface LoaderOptions {
61
61
  /**
62
+ * @deprecated It is now recommended to filter files on `source` level
62
63
  * @defaultValue `''`
63
64
  */
64
65
  rootDir?: string;
65
- /**
66
- * @defaultValue `'/'`
67
- */
68
- baseUrl?: string;
66
+ baseUrl: string;
69
67
  icon?: NonNullable<BuildPageTreeOptions['resolveIcon']>;
70
68
  slugs?: LoadOptions['getSlugs'];
71
69
  url?: UrlFn;
@@ -375,13 +375,11 @@ function loader(options) {
375
375
  return createOutput(options);
376
376
  }
377
377
  function createOutput(options) {
378
- const {
379
- source,
380
- rootDir = "",
381
- baseUrl = "/",
382
- slugs: slugsFn = getSlugs,
383
- url: getUrl = createGetUrl(baseUrl, options.i18n)
384
- } = options;
378
+ if (!options.url && !options.baseUrl) {
379
+ console.warn("`loader()` now requires a `baseUrl` option to be defined.");
380
+ }
381
+ const { source, rootDir = "", slugs: slugsFn = getSlugs } = options;
382
+ const getUrl = options.url ?? createGetUrl(options.baseUrl ?? "/", options.i18n);
385
383
  const storage = loadFiles(
386
384
  typeof source.files === "function" ? source.files(rootDir) : source.files,
387
385
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "14.6.8",
3
+ "version": "14.7.1",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -77,36 +77,37 @@
77
77
  "dist/*"
78
78
  ],
79
79
  "dependencies": {
80
- "@formatjs/intl-localematcher": "^0.5.9",
80
+ "@formatjs/intl-localematcher": "^0.5.10",
81
81
  "@orama/orama": "^2.1.1",
82
- "@shikijs/rehype": "^1.24.3",
82
+ "@shikijs/rehype": "^1.26.1",
83
83
  "github-slugger": "^2.0.0",
84
84
  "hast-util-to-estree": "^3.1.0",
85
85
  "hast-util-to-jsx-runtime": "^2.3.2",
86
- "image-size": "^1.1.1",
86
+ "image-size": "^1.2.0",
87
87
  "negotiator": "^1.0.0",
88
88
  "react-remove-scroll": "^2.6.2",
89
89
  "remark": "^15.0.0",
90
90
  "remark-gfm": "^4.0.0",
91
91
  "scroll-into-view-if-needed": "^3.1.0",
92
- "shiki": "^1.24.3",
92
+ "shiki": "^1.26.1",
93
93
  "unist-util-visit": "^5.0.0"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@algolia/client-search": "4.24.0",
97
97
  "@mdx-js/mdx": "^3.1.0",
98
+ "@orama/tokenizers": "^2.1.1",
98
99
  "@oramacloud/client": "^2.1.4",
99
100
  "@types/estree-jsx": "^1.0.5",
100
101
  "@types/hast": "^3.0.4",
101
102
  "@types/mdast": "^4.0.3",
102
103
  "@types/negotiator": "^0.6.3",
103
- "@types/node": "22.10.2",
104
+ "@types/node": "22.10.5",
104
105
  "@types/react": "^19.0.2",
105
106
  "@types/react-dom": "^19.0.2",
106
107
  "algoliasearch": "4.24.0",
107
108
  "mdast-util-mdx-jsx": "^3.1.3",
108
109
  "mdast-util-mdxjs-esm": "^2.0.1",
109
- "next": "^15.1.2",
110
+ "next": "^15.1.3",
110
111
  "remark-mdx": "^3.1.0",
111
112
  "remark-rehype": "^11.1.1",
112
113
  "shiki-transformers": "^1.0.1",
@@ -117,6 +118,7 @@
117
118
  "tsconfig": "0.0.0"
118
119
  },
119
120
  "peerDependencies": {
121
+ "@orama/tokenizers": "2.x.x",
120
122
  "@oramacloud/client": "1.x.x || 2.x.x",
121
123
  "algoliasearch": "4.24.0",
122
124
  "next": "14.x.x || 15.x.x",
@@ -124,6 +126,9 @@
124
126
  "react-dom": "18.x.x || 19.x.x"
125
127
  },
126
128
  "peerDependenciesMeta": {
129
+ "@orama/tokenizers": {
130
+ "optional": true
131
+ },
127
132
  "@oramacloud/client": {
128
133
  "optional": true
129
134
  },