@fumadocs/cli 1.7.4 → 1.7.5
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.
- package/dist/{all-BmTB7dab.js → all-DgAfTffR.js} +2 -2
- package/dist/{all-BmTB7dab.js.map → all-DgAfTffR.js.map} +1 -1
- package/dist/features/all.js +1 -1
- package/dist/features/og.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{og-m0CwRlRz.js → og-CY4RS9Un.js} +3 -1
- package/dist/{og-m0CwRlRz.js.map → og-CY4RS9Un.js.map} +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as docs } from "./docs-qRGwd9Yp.js";
|
|
2
2
|
import { t as ai } from "./ai-BoUGzPvv.js";
|
|
3
3
|
import { r as llms } from "./llms-DQzAst6R.js";
|
|
4
|
-
import { t as og } from "./og-
|
|
4
|
+
import { t as og } from "./og-CY4RS9Un.js";
|
|
5
5
|
import { t as search } from "./search-BCHEW0-K.js";
|
|
6
6
|
import { t as mcp } from "./mcp-BpFZ_fdV.js";
|
|
7
7
|
import { n as webmcp } from "./webmcp-I9L7xzmw.js";
|
|
@@ -24,4 +24,4 @@ const features = [
|
|
|
24
24
|
//#endregion
|
|
25
25
|
export { features as t };
|
|
26
26
|
|
|
27
|
-
//# sourceMappingURL=all-
|
|
27
|
+
//# sourceMappingURL=all-DgAfTffR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-
|
|
1
|
+
{"version":3,"file":"all-DgAfTffR.js","names":[],"sources":["../src/features/all.ts"],"sourcesContent":["import type { AnyFeature } from '.';\nimport { docs } from './docs';\nimport { ai } from './ai';\nimport { llms } from './llms';\nimport { og } from './og';\nimport { search } from './search';\nimport { mcp } from './mcp';\nimport { webmcp } from './webmcp';\nimport { feedback } from './feedback';\nimport { epub } from './epub';\nimport { lint } from './lint';\n\nexport const features: AnyFeature[] = [\n docs,\n ai,\n llms,\n mcp,\n webmcp,\n og,\n search,\n feedback,\n epub,\n lint,\n];\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,WAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
package/dist/features/all.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as features } from "../all-
|
|
1
|
+
import { t as features } from "../all-DgAfTffR.js";
|
|
2
2
|
export { features };
|
package/dist/features/og.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as og } from "../og-
|
|
1
|
+
import { t as og } from "../og-CY4RS9Un.js";
|
|
2
2
|
export { og };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { t as exists } from "./fs-D6J9dOEx.js";
|
|
|
5
5
|
import { i as loadProject, n as frameworks } from "./project-DwRVTm4p.js";
|
|
6
6
|
import { n as UIRegistries, t as FumadocsComponentInstaller } from "./installer-C4662Woc.js";
|
|
7
7
|
import { t as runFeature } from "./features-Do6x9Tsz.js";
|
|
8
|
-
import { t as features } from "./all-
|
|
8
|
+
import { t as features } from "./all-DgAfTffR.js";
|
|
9
9
|
import fs from "node:fs/promises";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { cac } from "cac";
|
|
@@ -66,7 +66,7 @@ async function runTree(args) {
|
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
68
|
//#region package.json
|
|
69
|
-
var version = "1.7.
|
|
69
|
+
var version = "1.7.5";
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region src/commands/customise.ts
|
|
72
72
|
async function customise(config, connector) {
|
|
@@ -133,10 +133,12 @@ const og = {
|
|
|
133
133
|
if (config && !getProperty(config, "serverExternalPackages")) addElements(file, config, ["serverExternalPackages: ['@takumi-rs/core']"]);
|
|
134
134
|
});
|
|
135
135
|
if (framework === "next" && i18n) await extendNextProxy(ctx, route);
|
|
136
|
+
if (ctx.project.static && framework === "react-router") ctx.note("Image routes are dynamic, add `getPageImageUrl(page).url` of each page to your prerender config.");
|
|
137
|
+
else if (ctx.project.static && framework === "tanstack-start") ctx.note("TanStack Start prerenders responses as text, which breaks images. Prerender the image routes with Nitro instead, see https://fumadocs.dev/docs/integrations/og/takumi.");
|
|
136
138
|
ctx.note("The image URL of a page is `getPageImageUrl(page).url` from '@/lib/shared', reference it in the page metadata (e.g. `og:image`).");
|
|
137
139
|
}
|
|
138
140
|
};
|
|
139
141
|
//#endregion
|
|
140
142
|
export { og as t };
|
|
141
143
|
|
|
142
|
-
//# sourceMappingURL=og-
|
|
144
|
+
//# sourceMappingURL=og-CY4RS9Un.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"og-
|
|
1
|
+
{"version":3,"file":"og-CY4RS9Un.js","names":[],"sources":["../src/features/og.ts"],"sourcesContent":["import path from 'node:path';\nimport type { Feature } from '@/features';\nimport type { ReactFramework } from '@/project';\nimport { type FormattedRoute, formatRoute, reactRouterTypes } from '@/project/route';\nimport { addElements, getConfigObject, getProperty } from '@/codemod';\nimport { docs } from './docs';\nimport { extendNextProxy } from './llms';\nimport {\n addPageUrl,\n reactFramework,\n registerReactRouterRoutes,\n sharedRoute,\n type SourceRef,\n sourceRef,\n} from './utils';\n\ntype Engine = 'takumi' | 'next-og';\n\n/** the image URL of a page, `/og/docs/<slugs>/image.png` */\nconst imageUrl = (ext: string, i18n: boolean) => `\nconst getImageUrl = createGetUrl(docsImageRoute${i18n ? ', i18n' : ''});\n\nexport function getPageImageUrl(page: { slugs: string[]; locale?: string }) {\n const segments = [...page.slugs, 'image.${ext}'];\n\n return { segments, url: getImageUrl(segments, page.locale) };\n}`;\n\nconst imports = (engine: Engine) =>\n `import { generateOGImage } from 'fumadocs-ui/og${engine === 'takumi' ? '/takumi' : ''}';`;\n\nconst image = (engine: Engine) => `generateOGImage({\n title: page.data.title,\n description: page.data.description,\n site: 'My App',${engine === 'takumi' ? \"\\n format: 'webp',\" : ''}\n })`;\n\nconst ext = (engine: Engine) => (engine === 'takumi' ? 'webp' : 'png');\n\ntype Template = (route: FormattedRoute, engine: Engine, i18n: boolean, src: SourceRef) => string;\n\nconst templates: Record<ReactFramework, Template> = {\n next: (route, engine, i18n, src) => `import { ${src.ref} } from '@/lib/source';\nimport { notFound } from 'next/navigation';\n${imports(engine)}\n\nexport const revalidate = false;\n\nexport async function GET(_req: Request, { params }: RouteContext<'${route.path}'>) {\n const { slug${i18n ? ', lang' : ''} } = await params;\n const page = ${src.resolved}.getPage(slug.slice(0, -1)${i18n ? ', lang' : ''});\n if (!page) notFound();\n\n return ${image(engine)};\n}\n\nexport ${src.dynamic ? 'async ' : ''}function generateStaticParams() {\n return ${src.resolved}.generateParams().map((item) => ({\n ...item,\n slug: [...item.slug, 'image.${ext(engine)}'],\n }));\n}\n`,\n 'react-router': (route, engine, i18n, src) => `${reactRouterTypes(route)}\nimport { ${src.ref} } from '@/lib/source';\n${imports(engine)}\n\nexport async function loader({ params }: Route.LoaderArgs) {\n const slugs = params['*'].split('/').filter((v) => v.length > 0);\n const page = ${src.resolved}.getPage(slugs.slice(0, -1)${i18n ? ', params.lang' : ''});\n if (!page) throw new Response(undefined, { status: 404 });\n\n return ${image(engine)};\n}\n`,\n 'tanstack-start': (\n route,\n engine,\n i18n,\n src,\n ) => `import { createFileRoute } from '@tanstack/react-router';\nimport { ${src.ref} } from '@/lib/source';\n${imports(engine)}\n\nexport const Route = createFileRoute('${route.path}')({\n server: {\n handlers: {\n GET: async ({ params }) => {\n const slugs = params._splat?.split('/') ?? [];\n const page = ${src.resolved}.getPage(slugs.slice(0, -1)${i18n ? ', params.lang' : ''});\n if (!page) return new Response(undefined, { status: 404 });\n\n return ${image(engine).replaceAll('\\n ', '\\n ')};\n },\n },\n },\n});\n`,\n waku: (route, engine, i18n, src) => `import { ${src.ref} } from '@/lib/source';\nimport type { ApiContext } from 'waku/router';\n${imports(engine)}\n\nexport async function GET(_: Request, { params }: ApiContext<'${route.path}'>) {\n const page = ${src.resolved}.getPage(params.slug${i18n ? ', params.lang' : ''});\n if (!page) return new Response(undefined, { status: 404 });\n\n return ${image(engine)};\n}\n\nexport async function getConfig() {\n return {\n render: 'static' as const,\n staticPaths: ${src.resolved}.generateParams().map((item) => ${i18n ? '[item.lang, ...item.slug]' : 'item.slug'}),\n } as const;\n}\n`,\n};\n\nexport const og: Feature<{ engine: Engine }> = {\n id: 'og',\n title: 'OG Image',\n description: 'generate Open Graph images for docs pages',\n requires: [docs],\n options: {\n engine: {\n message: 'Choose an image engine',\n choices: [\n { value: 'takumi', label: 'Takumi', hint: 'outputs WebP, framework-agnostic' },\n { value: 'next-og', label: 'next/og', hint: 'Next.js built-in solution' },\n ],\n },\n },\n async apply(ctx, { engine }) {\n const { baseDir, configFile, i18n, source } = ctx.project;\n const framework = reactFramework(ctx.project);\n if (engine === 'next-og' && framework !== 'next')\n throw new Error('next/og is only available on Next.js');\n if (engine === 'takumi') ctx.addDependencies({ 'takumi-js': null });\n\n const shared = path.join(baseDir, 'lib/shared.ts');\n const imageRoute = await sharedRoute(\n ctx,\n 'docsImageRoute',\n `/og${source.baseUrl.replace(/\\/$/, '')}`,\n );\n const added = await addPageUrl(ctx, 'getPageImageUrl', imageUrl(ext(engine), i18n !== null));\n if (!added && engine === 'takumi') {\n await ctx.source(shared, (file) => {\n file.s.replaceAll('image.png', 'image.webp');\n });\n }\n\n const route = formatRoute(\n {\n segments: [imageRoute, { param: 'slug', catchAll: true, suffix: `image.${ext(engine)}` }],\n locale: true,\n },\n framework,\n i18n,\n 'tsx',\n );\n await ctx.write(\n path.join(baseDir, route.file),\n templates[framework](route, engine, i18n !== null, sourceRef(ctx.project.source.dynamic)),\n );\n\n if (framework === 'react-router') await registerReactRouterRoutes(ctx, [route]);\n if (framework === 'next' && engine === 'takumi' && configFile) {\n await ctx.source(configFile, (file) => {\n const config = getConfigObject(file);\n if (config && !getProperty(config, 'serverExternalPackages'))\n addElements(file, config, [\"serverExternalPackages: ['@takumi-rs/core']\"]);\n });\n }\n if (framework === 'next' && i18n) await extendNextProxy(ctx, route);\n if (ctx.project.static && framework === 'react-router') {\n ctx.note(\n 'Image routes are dynamic, add `getPageImageUrl(page).url` of each page to your prerender config.',\n );\n } else if (ctx.project.static && framework === 'tanstack-start') {\n ctx.note(\n 'TanStack Start prerenders responses as text, which breaks images. Prerender the image routes with Nitro instead, see https://fumadocs.dev/docs/integrations/og/takumi.',\n );\n }\n\n ctx.note(\n \"The image URL of a page is `getPageImageUrl(page).url` from '@/lib/shared', reference it in the page metadata (e.g. `og:image`).\",\n );\n },\n};\n"],"mappings":";;;;;;;AAmBA,MAAM,YAAY,KAAa,SAAkB;iDACA,OAAO,WAAW,GAAG;;;4CAG1B,IAAI;;;;AAKhD,MAAM,WAAW,WACf,kDAAkD,WAAW,WAAW,YAAY,GAAG;AAEzF,MAAM,SAAS,WAAmB;;;qBAGb,WAAW,WAAW,0BAA0B,GAAG;;AAGxE,MAAM,OAAO,WAAoB,WAAW,WAAW,SAAS;AAIhE,MAAM,YAA8C;CAClD,OAAO,OAAO,QAAQ,MAAM,QAAQ,YAAY,IAAI,IAAI;;EAExD,QAAQ,MAAM,EAAE;;;;qEAImD,MAAM,KAAK;gBAChE,OAAO,WAAW,GAAG;iBACpB,IAAI,SAAS,4BAA4B,OAAO,WAAW,GAAG;;;WAGpE,MAAM,MAAM,EAAE;;;SAGhB,IAAI,UAAU,WAAW,GAAG;WAC1B,IAAI,SAAS;;kCAEU,IAAI,MAAM,EAAE;;;;CAI5C,iBAAiB,OAAO,QAAQ,MAAM,QAAQ,GAAG,iBAAiB,KAAK,EAAE;WAChE,IAAI,IAAI;EACjB,QAAQ,MAAM,EAAE;;;;iBAID,IAAI,SAAS,6BAA6B,OAAO,kBAAkB,GAAG;;;WAG5E,MAAM,MAAM,EAAE;;;CAGvB,mBACE,OACA,QACA,MACA,QACG;WACI,IAAI,IAAI;EACjB,QAAQ,MAAM,EAAE;;wCAEsB,MAAM,KAAK;;;;;uBAK5B,IAAI,SAAS,6BAA6B,OAAO,k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