fumadocs-core 13.4.5 → 13.4.6

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.
@@ -34,6 +34,10 @@ interface VirtualFile {
34
34
  */
35
35
  path: string;
36
36
  type: 'page' | 'meta';
37
+ /**
38
+ * Specified Slugs for page
39
+ */
40
+ slugs?: string[];
37
41
  data: unknown;
38
42
  }
39
43
  type Transformer = (context: {
@@ -122,6 +126,10 @@ interface LoaderOutput<Config extends LoaderConfig> {
122
126
  * @param language - If empty, the default language will be used
123
127
  */
124
128
  getPage: (slugs: string[] | undefined, language?: string) => Page<Config['source']['pageData']> | undefined;
129
+ /**
130
+ * generate static params for Next.js SSG
131
+ */
132
+ generateParams: <TSlug extends string = 'slug', TLang extends string = 'lang'>(slug?: TSlug, lang?: TLang) => (Record<TSlug, string[]> & Record<TLang, string>)[];
125
133
  }
126
134
  declare function createGetUrl(baseUrl: string): UrlFn;
127
135
  declare function getSlugs(info: FileInfo): string[];
@@ -321,8 +321,7 @@ function loadFiles(files, options) {
321
321
  if (!normalizedPath.startsWith(rootDir)) continue;
322
322
  const relativePath = normalizedPath.slice(rootDir.length);
323
323
  if (file.type === "page") {
324
- const parsedPath = parseFilePath(relativePath);
325
- const slugs = options.getSlugs(parsedPath);
324
+ const slugs = file.slugs ?? options.getSlugs(parseFilePath(relativePath));
326
325
  storage.write(relativePath, file.type, {
327
326
  slugs,
328
327
  data: file.data
@@ -447,6 +446,20 @@ function createOutput({
447
446
  },
448
447
  getPage(slugs = [], language = i18n?.defaultLanguage ?? "") {
449
448
  return i18nMap.get(language)?.get(slugs.join("/"));
449
+ },
450
+ // @ts-expect-error -- ignore this
451
+ generateParams(slug, lang) {
452
+ if (i18n) {
453
+ return this.getLanguages().flatMap(
454
+ (entry) => entry.pages.map((page) => ({
455
+ [slug ?? "slug"]: page.slugs,
456
+ [lang ?? "lang"]: entry.language
457
+ }))
458
+ );
459
+ }
460
+ return Array.from(i18nMap.get("")?.values() ?? []).map((page) => ({
461
+ [slug ?? "slug"]: page.slugs
462
+ }));
450
463
  }
451
464
  };
452
465
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "13.4.5",
3
+ "version": "13.4.6",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -127,8 +127,8 @@
127
127
  ],
128
128
  "dependencies": {
129
129
  "@formatjs/intl-localematcher": "^0.5.4",
130
- "@shikijs/rehype": "^1.16.1",
131
- "@shikijs/transformers": "^1.16.1",
130
+ "@shikijs/rehype": "^1.16.2",
131
+ "@shikijs/transformers": "^1.16.2",
132
132
  "flexsearch": "0.7.21",
133
133
  "github-slugger": "^2.0.0",
134
134
  "image-size": "^1.1.1",
@@ -139,7 +139,7 @@
139
139
  "remark-gfm": "^4.0.0",
140
140
  "remark-mdx": "^3.0.1",
141
141
  "scroll-into-view-if-needed": "^3.1.0",
142
- "shiki": "^1.16.1",
142
+ "shiki": "^1.16.2",
143
143
  "swr": "^2.2.5",
144
144
  "unist-util-visit": "^5.0.0"
145
145
  },
@@ -151,11 +151,11 @@
151
151
  "@types/hast": "^3.0.4",
152
152
  "@types/mdast": "^4.0.3",
153
153
  "@types/negotiator": "^0.6.3",
154
- "@types/node": "22.5.2",
154
+ "@types/node": "22.5.4",
155
155
  "@types/react": "^18.3.5",
156
156
  "@types/react-dom": "^18.3.0",
157
157
  "algoliasearch": "^4.24.0",
158
- "next": "^14.2.7",
158
+ "next": "^14.2.8",
159
159
  "unified": "^11.0.5",
160
160
  "eslint-config-custom": "0.0.0",
161
161
  "tsconfig": "0.0.0"