create-fumadocs-app 16.0.32 → 16.0.34
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/bin.d.ts +1 -1
- package/dist/bin.js +155 -206
- package/dist/bin.js.map +1 -0
- package/dist/constants-CReWPhck.js +150 -0
- package/dist/constants-CReWPhck.js.map +1 -0
- package/dist/index-CC4EFQ5p.d.ts +67 -0
- package/dist/index-CC4EFQ5p.d.ts.map +1 -0
- package/dist/index.d.ts +2 -63
- package/dist/index.js +4 -7
- package/dist/plugins/biome.base.d.ts +40 -45
- package/dist/plugins/biome.base.d.ts.map +1 -0
- package/dist/plugins/biome.base.js +37 -17
- package/dist/plugins/biome.base.js.map +1 -0
- package/dist/plugins/biome.d.ts +4 -2
- package/dist/plugins/biome.d.ts.map +1 -0
- package/dist/plugins/biome.js +30 -40
- package/dist/plugins/biome.js.map +1 -0
- package/dist/plugins/biome.next.d.ts +41 -49
- package/dist/plugins/biome.next.d.ts.map +1 -0
- package/dist/plugins/biome.next.js +43 -17
- package/dist/plugins/biome.next.js.map +1 -0
- package/dist/plugins/eslint.d.ts +4 -2
- package/dist/plugins/eslint.d.ts.map +1 -0
- package/dist/plugins/eslint.js +30 -33
- package/dist/plugins/eslint.js.map +1 -0
- package/dist/plugins/next-use-src.d.ts +5 -2
- package/dist/plugins/next-use-src.d.ts.map +1 -0
- package/dist/plugins/next-use-src.js +33 -35
- package/dist/plugins/next-use-src.js.map +1 -0
- package/dist/plugins/orama-cloud.d.ts +4 -2
- package/dist/plugins/orama-cloud.d.ts.map +1 -0
- package/dist/plugins/orama-cloud.js +210 -276
- package/dist/plugins/orama-cloud.js.map +1 -0
- package/dist/src-DWqRvlfn.js +89 -0
- package/dist/src-DWqRvlfn.js.map +1 -0
- package/package.json +19 -18
- package/template/+next+fuma-docs-mdx/app/docs/[[...slug]]/page.tsx +2 -9
- package/template/+next+fuma-docs-mdx/app/docs/layout.tsx +1 -1
- package/template/+next+fuma-docs-mdx/app/og/docs/[...slug]/route.tsx +2 -9
- package/template/+next+fuma-docs-mdx/package.json +2 -2
- package/template/+next+fuma-docs-mdx/source.config.ts +1 -6
- package/template/+orama-cloud/@app/components/search.tsx +1 -6
- package/template/react-router/app/docs/page.tsx +1 -6
- package/template/react-router/app/root.tsx +1 -3
- package/template/react-router/package.json +6 -6
- package/template/react-router/tsconfig.json +1 -6
- package/template/react-router-spa/app/components/search.tsx +1 -6
- package/template/react-router-spa/app/docs/page.tsx +2 -7
- package/template/react-router-spa/app/root.tsx +1 -3
- package/template/react-router-spa/package.json +6 -6
- package/template/react-router-spa/tsconfig.json +1 -6
- package/template/tanstack-start/content/docs/index.mdx +1 -4
- package/template/tanstack-start/package.json +4 -4
- package/template/tanstack-start/src/components/not-found.tsx +2 -2
- package/template/tanstack-start/src/routes/__root.tsx +1 -6
- package/template/tanstack-start/src/routes/docs/$.tsx +1 -6
- package/template/tanstack-start/src/routes/index.tsx +1 -3
- package/template/tanstack-start-spa/content/docs/index.mdx +1 -4
- package/template/tanstack-start-spa/package.json +5 -5
- package/template/tanstack-start-spa/src/components/not-found.tsx +2 -2
- package/template/tanstack-start-spa/src/components/search.tsx +1 -6
- package/template/tanstack-start-spa/src/routes/__root.tsx +1 -6
- package/template/tanstack-start-spa/src/routes/docs/$.tsx +2 -7
- package/template/waku/package.json +4 -4
- package/template/waku/src/pages/docs/[...slugs].tsx +2 -9
- package/template/waku/src/pages/docs/_layout.tsx +1 -1
- package/dist/chunk-BEZTHMLF.js +0 -51
- package/dist/chunk-CYYUEPDV.js +0 -179
- package/dist/chunk-JCFTHRDR.js +0 -50
- package/dist/chunk-Y54WH7LQ.js +0 -130
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/next-use-src.ts
|
|
5
|
+
/**
|
|
6
|
+
* Use `src` for app directory
|
|
7
|
+
*/
|
|
4
8
|
function nextUseSrc() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Object.assign(config.compilerOptions.paths, {
|
|
27
|
-
"@/*": ["./src/*"]
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
await fs.writeFile(tsconfigPath, JSON.stringify(config, null, 2));
|
|
31
|
-
}
|
|
32
|
-
};
|
|
9
|
+
return {
|
|
10
|
+
template(info) {
|
|
11
|
+
if (info.value !== "+next+fuma-docs-mdx") return;
|
|
12
|
+
return {
|
|
13
|
+
...info,
|
|
14
|
+
appDir: "src",
|
|
15
|
+
rename: (file) => {
|
|
16
|
+
if (path.basename(file) === "mdx-components.tsx" || isRelative(path.join(this.dest, "app"), file) || isRelative(path.join(this.dest, "lib"), file)) return path.join(this.dest, "src", path.relative(this.dest, file));
|
|
17
|
+
return file;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
async afterWrite() {
|
|
22
|
+
if (this.template.value !== "+next+fuma-docs-mdx") return;
|
|
23
|
+
const tsconfigPath = path.join(this.dest, "tsconfig.json");
|
|
24
|
+
const content = (await fs.readFile(tsconfigPath)).toString();
|
|
25
|
+
const config = JSON.parse(content);
|
|
26
|
+
if (config.compilerOptions?.paths) Object.assign(config.compilerOptions.paths, { "@/*": ["./src/*"] });
|
|
27
|
+
await fs.writeFile(tsconfigPath, JSON.stringify(config, null, 2));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
33
30
|
}
|
|
34
31
|
function isRelative(dir, file) {
|
|
35
|
-
|
|
32
|
+
return !path.relative(dir, file).startsWith(`..${path.sep}`);
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { nextUseSrc };
|
|
37
|
+
//# sourceMappingURL=next-use-src.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-use-src.js","names":[],"sources":["../../src/plugins/next-use-src.ts"],"sourcesContent":["import { TemplatePlugin } from '@/index';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\n\n/**\n * Use `src` for app directory\n */\nexport function nextUseSrc(): TemplatePlugin {\n return {\n template(info) {\n if (info.value !== '+next+fuma-docs-mdx') return;\n\n return {\n ...info,\n appDir: 'src',\n rename: (file) => {\n if (\n path.basename(file) === 'mdx-components.tsx' ||\n isRelative(path.join(this.dest, 'app'), file) ||\n isRelative(path.join(this.dest, 'lib'), file)\n ) {\n return path.join(this.dest, 'src', path.relative(this.dest, file));\n }\n\n return file;\n },\n };\n },\n // update tsconfig.json for src dir\n async afterWrite() {\n if (this.template.value !== '+next+fuma-docs-mdx') return;\n\n const tsconfigPath = path.join(this.dest, 'tsconfig.json');\n const content = (await fs.readFile(tsconfigPath)).toString();\n const config = JSON.parse(content);\n\n if (config.compilerOptions?.paths) {\n Object.assign(config.compilerOptions.paths, {\n '@/*': ['./src/*'],\n });\n }\n\n await fs.writeFile(tsconfigPath, JSON.stringify(config, null, 2));\n },\n };\n}\n\nfunction isRelative(dir: string, file: string) {\n return !path.relative(dir, file).startsWith(`..${path.sep}`);\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,aAA6B;AAC3C,QAAO;EACL,SAAS,MAAM;AACb,OAAI,KAAK,UAAU,sBAAuB;AAE1C,UAAO;IACL,GAAG;IACH,QAAQ;IACR,SAAS,SAAS;AAChB,SACE,KAAK,SAAS,KAAK,KAAK,wBACxB,WAAW,KAAK,KAAK,KAAK,MAAM,MAAM,EAAE,KAAK,IAC7C,WAAW,KAAK,KAAK,KAAK,MAAM,MAAM,EAAE,KAAK,CAE7C,QAAO,KAAK,KAAK,KAAK,MAAM,OAAO,KAAK,SAAS,KAAK,MAAM,KAAK,CAAC;AAGpE,YAAO;;IAEV;;EAGH,MAAM,aAAa;AACjB,OAAI,KAAK,SAAS,UAAU,sBAAuB;GAEnD,MAAM,eAAe,KAAK,KAAK,KAAK,MAAM,gBAAgB;GAC1D,MAAM,WAAW,MAAM,GAAG,SAAS,aAAa,EAAE,UAAU;GAC5D,MAAM,SAAS,KAAK,MAAM,QAAQ;AAElC,OAAI,OAAO,iBAAiB,MAC1B,QAAO,OAAO,OAAO,gBAAgB,OAAO,EAC1C,OAAO,CAAC,UAAU,EACnB,CAAC;AAGJ,SAAM,GAAG,UAAU,cAAc,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC;;EAEpE;;AAGH,SAAS,WAAW,KAAa,MAAc;AAC7C,QAAO,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC,WAAW,KAAK,KAAK,MAAM"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { TemplatePlugin } from
|
|
1
|
+
import { i as TemplatePlugin } from "../index-CC4EFQ5p.js";
|
|
2
2
|
|
|
3
|
+
//#region src/plugins/orama-cloud.d.ts
|
|
3
4
|
declare function oramaCloud(): TemplatePlugin;
|
|
4
|
-
|
|
5
|
+
//#endregion
|
|
5
6
|
export { oramaCloud };
|
|
7
|
+
//# sourceMappingURL=orama-cloud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orama-cloud.d.ts","names":[],"sources":["../../src/plugins/orama-cloud.ts"],"sourcesContent":[],"mappings":";;;iBAOgB,UAAA,CAAA,GAAc"}
|
|
@@ -1,300 +1,234 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
sourceDir,
|
|
6
|
-
writeFile
|
|
7
|
-
} from "../chunk-CYYUEPDV.js";
|
|
1
|
+
import { a as copy, c as writeFile, o as pick, r as sourceDir, t as depVersions } from "../constants-CReWPhck.js";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { IndentationText, Project, QuoteKind, StructureKind, SyntaxKind, ts } from "ts-morph";
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var project = new Project({
|
|
17
|
-
manipulationSettings: {
|
|
18
|
-
indentationText: IndentationText.TwoSpaces,
|
|
19
|
-
quoteKind: QuoteKind.Single
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
async function createSourceFile(path3) {
|
|
23
|
-
return project.createSourceFile(path3, (await fs.readFile(path3)).toString(), {
|
|
24
|
-
overwrite: true
|
|
25
|
-
});
|
|
6
|
+
//#region src/transform/shared.ts
|
|
7
|
+
const project = new Project({ manipulationSettings: {
|
|
8
|
+
indentationText: IndentationText.TwoSpaces,
|
|
9
|
+
quoteKind: QuoteKind.Single
|
|
10
|
+
} });
|
|
11
|
+
async function createSourceFile(path$1) {
|
|
12
|
+
return project.createSourceFile(path$1, (await fs.readFile(path$1)).toString(), { overwrite: true });
|
|
26
13
|
}
|
|
27
14
|
function getCodeValue(v) {
|
|
28
|
-
|
|
15
|
+
return new Function(`return ${v}`)();
|
|
29
16
|
}
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} from "ts-morph";
|
|
38
|
-
var SyntaxKind = ts.SyntaxKind;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/transform/react-router.ts
|
|
20
|
+
var SyntaxKind$1 = ts.SyntaxKind;
|
|
21
|
+
/**
|
|
22
|
+
* filter items in a specific array initializer in the prerender function
|
|
23
|
+
*/
|
|
39
24
|
function filterReactRouterPrerenderArray(sourceFile, array, filter) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!filter(getCodeValue(element.getText()))) {
|
|
46
|
-
initializer.removeElement(element);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
25
|
+
const methodBody = getPrerenderMethod(sourceFile)?.getBody();
|
|
26
|
+
if (!methodBody) return;
|
|
27
|
+
const initializer = methodBody.getDescendantsOfKind(SyntaxKind$1.VariableDeclaration).find((item) => item.getName() === array)?.getInitializerIfKind(SyntaxKind$1.ArrayLiteralExpression);
|
|
28
|
+
if (!initializer) return;
|
|
29
|
+
for (const element of initializer.getElements()) if (!filter(getCodeValue(element.getText()))) initializer.removeElement(element);
|
|
49
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Add a new route to route config
|
|
33
|
+
*/
|
|
50
34
|
function addReactRouterRoute(sourceFile, routes) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
});
|
|
35
|
+
modifyReactRouterRoutes(sourceFile, (arr) => {
|
|
36
|
+
for (const { path: path$1, entry } of routes) arr.addElement(`route('${path$1}', '${entry}')`);
|
|
37
|
+
});
|
|
56
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Remove routes from route config (root level only)
|
|
41
|
+
*/
|
|
57
42
|
function filterReactRouterRoute(sourceFile, filter) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
});
|
|
43
|
+
modifyReactRouterRoutes(sourceFile, (arr) => {
|
|
44
|
+
for (const element of arr.getElements()) {
|
|
45
|
+
if (!element.isKind(SyntaxKind$1.CallExpression) || element.getFirstChildByKind(SyntaxKind$1.Identifier)?.getText() !== "route") continue;
|
|
46
|
+
const args = element.getArguments();
|
|
47
|
+
if (filter({
|
|
48
|
+
path: getCodeValue(args[0].getText()),
|
|
49
|
+
entry: getCodeValue(args[1].getText())
|
|
50
|
+
})) continue;
|
|
51
|
+
arr.removeElement(element);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
71
54
|
}
|
|
72
55
|
function modifyReactRouterRoutes(sourceFile, mod) {
|
|
73
|
-
|
|
74
|
-
|
|
56
|
+
const initializer = sourceFile.getDefaultExportSymbol()?.getValueDeclaration()?.getFirstDescendantByKind(SyntaxKind$1.ArrayLiteralExpression);
|
|
57
|
+
if (initializer) mod(initializer);
|
|
75
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Find the prerender method from the config
|
|
61
|
+
*/
|
|
76
62
|
function getPrerenderMethod(sourceFile) {
|
|
77
|
-
|
|
63
|
+
return sourceFile.getDefaultExportSymbol()?.getValueDeclaration()?.getFirstDescendantByKind(SyntaxKind$1.ObjectLiteralExpression)?.getProperty("prerender")?.asKind(SyntaxKind$1.MethodDeclaration) ?? null;
|
|
78
64
|
}
|
|
79
65
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/transform/tanstack-start.ts
|
|
68
|
+
/**
|
|
69
|
+
* Add path to the `pages` array in tanstack start vite config.
|
|
70
|
+
*
|
|
71
|
+
* If the `pages` property doesn't exist, create one.
|
|
72
|
+
*/
|
|
85
73
|
function addTanstackPrerender(sourceFile, paths) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
for (const path3 of paths) {
|
|
106
|
-
if (existingPaths.has(path3)) continue;
|
|
107
|
-
initializer.addElement(toItem(path3));
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
optionsArg.addProperty(
|
|
111
|
-
`pages: [
|
|
112
|
-
${paths.map((path3) => ` ${toItem(path3)}`).join(",\n")}
|
|
113
|
-
]`
|
|
114
|
-
);
|
|
115
|
-
}
|
|
74
|
+
const optionsArg = getTanstackStartCall(sourceFile)?.getArguments()[0]?.asKind(SyntaxKind.ObjectLiteralExpression);
|
|
75
|
+
if (!optionsArg) return;
|
|
76
|
+
const pagesProperty = optionsArg.getProperty("pages")?.asKind(SyntaxKind.PropertyAssignment);
|
|
77
|
+
function toItem(path$1) {
|
|
78
|
+
return `{ path: '${path$1}' }`;
|
|
79
|
+
}
|
|
80
|
+
if (pagesProperty) {
|
|
81
|
+
const initializer = pagesProperty.getInitializerIfKindOrThrow(SyntaxKind.ArrayLiteralExpression);
|
|
82
|
+
const existingPaths = /* @__PURE__ */ new Set();
|
|
83
|
+
for (const element of initializer.getElements()) {
|
|
84
|
+
const value = element.asKind(SyntaxKind.ObjectLiteralExpression)?.getProperty("path")?.asKind(SyntaxKind.PropertyAssignment)?.getInitializer()?.getText();
|
|
85
|
+
if (value) existingPaths.add(getCodeValue(value));
|
|
86
|
+
}
|
|
87
|
+
for (const path$1 of paths) {
|
|
88
|
+
if (existingPaths.has(path$1)) continue;
|
|
89
|
+
initializer.addElement(toItem(path$1));
|
|
90
|
+
}
|
|
91
|
+
} else optionsArg.addProperty(`pages: [\n${paths.map((path$1) => ` ${toItem(path$1)}`).join(",\n")}\n]`);
|
|
116
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Find the tanstackStart call expression
|
|
95
|
+
*/
|
|
117
96
|
function getTanstackStartCall(sourceFile) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}
|
|
97
|
+
const pluginsProperty = sourceFile.getDefaultExportSymbol()?.getValueDeclaration()?.getFirstDescendantByKind(SyntaxKind.ObjectLiteralExpression)?.getProperty("plugins")?.getFirstChildByKind(SyntaxKind.ArrayLiteralExpression);
|
|
98
|
+
if (!pluginsProperty) return;
|
|
99
|
+
for (const element of pluginsProperty.getElements()) {
|
|
100
|
+
const expression = element.asKind(SyntaxKind.CallExpression);
|
|
101
|
+
if (expression?.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === "tanstackStart") return expression;
|
|
102
|
+
}
|
|
126
103
|
}
|
|
127
104
|
|
|
128
|
-
|
|
129
|
-
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/transform/index.ts
|
|
130
107
|
async function rootProvider({ appDir, template }, fn) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
file.addImportDeclaration({
|
|
152
|
-
moduleSpecifier: specifier,
|
|
153
|
-
defaultImport: "SearchDialog"
|
|
154
|
-
});
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
await file.save();
|
|
108
|
+
const file = await createSourceFile(path.join(appDir, template.rootProviderPath));
|
|
109
|
+
fn({ addSearchDialog(specifier) {
|
|
110
|
+
const elements = file.getDescendantsOfKind(SyntaxKind.JsxElement);
|
|
111
|
+
for (const element of elements) {
|
|
112
|
+
const provider = element.getFirstChildByKind(SyntaxKind.JsxOpeningElement);
|
|
113
|
+
if (provider?.getTagNameNode().getText() !== "RootProvider") continue;
|
|
114
|
+
if (provider.getAttributes().some((attr) => attr.isKind(SyntaxKind.JsxAttribute) && attr.getNameNode().getText() === "search")) continue;
|
|
115
|
+
provider.addAttribute({
|
|
116
|
+
kind: StructureKind.JsxAttribute,
|
|
117
|
+
name: "search",
|
|
118
|
+
initializer: "{{ SearchDialog }}"
|
|
119
|
+
});
|
|
120
|
+
file.addImportDeclaration({
|
|
121
|
+
moduleSpecifier: specifier,
|
|
122
|
+
defaultImport: "SearchDialog"
|
|
123
|
+
});
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
} });
|
|
127
|
+
await file.save();
|
|
160
128
|
}
|
|
161
129
|
async function reactRouterRoutes({ dest, appDir }, fn) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
(item) => normalizePath(item) !== normalizedPath
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
await Promise.all([...tasks, routesFile.save(), configFile.save()]);
|
|
130
|
+
const configFile = await createSourceFile(path.join(dest, "react-router.config.ts"));
|
|
131
|
+
const routesFile = await createSourceFile(path.join(appDir, "routes.ts"));
|
|
132
|
+
const tasks = [];
|
|
133
|
+
function normalizePath(v) {
|
|
134
|
+
return v.split("/").filter(Boolean).join("/");
|
|
135
|
+
}
|
|
136
|
+
fn({
|
|
137
|
+
addRoute: (p, entry, code) => {
|
|
138
|
+
addReactRouterRoute(routesFile, [{
|
|
139
|
+
path: p,
|
|
140
|
+
entry
|
|
141
|
+
}]);
|
|
142
|
+
if (code) tasks.push(fs.writeFile(path.join(appDir, entry), code));
|
|
143
|
+
},
|
|
144
|
+
removeRoute: (p) => {
|
|
145
|
+
const normalizedPath = normalizePath(p);
|
|
146
|
+
filterReactRouterRoute(routesFile, (item) => {
|
|
147
|
+
if (normalizePath(item.path) !== normalizedPath) return true;
|
|
148
|
+
tasks.push(fs.unlink(path.join(appDir, item.entry)).catch(() => null));
|
|
149
|
+
return false;
|
|
150
|
+
});
|
|
151
|
+
filterReactRouterPrerenderArray(configFile, "excluded", (item) => normalizePath(item) !== normalizedPath);
|
|
152
|
+
filterReactRouterPrerenderArray(configFile, "paths", (item) => normalizePath(item) !== normalizedPath);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
await Promise.all([
|
|
156
|
+
...tasks,
|
|
157
|
+
routesFile.save(),
|
|
158
|
+
configFile.save()
|
|
159
|
+
]);
|
|
197
160
|
}
|
|
198
161
|
async function tanstackStartRoutes({ appDir, dest }, fn) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
},
|
|
212
|
-
removeRoute(options) {
|
|
213
|
-
tasks.push(
|
|
214
|
-
fs2.unlink(path.join(appDir, "routes", options.path)).catch(() => null)
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
await Promise.all([...tasks, configFile.save()]);
|
|
162
|
+
const configFile = await createSourceFile(path.join(dest, "vite.config.ts"));
|
|
163
|
+
const tasks = [];
|
|
164
|
+
fn({
|
|
165
|
+
addRoute(options) {
|
|
166
|
+
if (options.code) tasks.push(fs.writeFile(path.join(appDir, "routes", options.path), options.code));
|
|
167
|
+
if (options.prerender) addTanstackPrerender(configFile, [options.route]);
|
|
168
|
+
},
|
|
169
|
+
removeRoute(options) {
|
|
170
|
+
tasks.push(fs.unlink(path.join(appDir, "routes", options.path)).catch(() => null));
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
await Promise.all([...tasks, configFile.save()]);
|
|
219
174
|
}
|
|
220
175
|
|
|
221
|
-
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/plugins/orama-cloud.ts
|
|
222
178
|
function oramaCloud() {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
## Orama Cloud
|
|
179
|
+
return {
|
|
180
|
+
packageJson(packageJson) {
|
|
181
|
+
return {
|
|
182
|
+
...packageJson,
|
|
183
|
+
scripts: {
|
|
184
|
+
...packageJson.scripts,
|
|
185
|
+
build: `${packageJson.scripts.build} && bun scripts/sync-content.ts`
|
|
186
|
+
},
|
|
187
|
+
dependencies: {
|
|
188
|
+
...packageJson.dependencies,
|
|
189
|
+
...pick(depVersions, ["@orama/core"])
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
readme(content) {
|
|
194
|
+
return `${content}\n\n## Orama Cloud
|
|
241
195
|
|
|
242
196
|
This project uses Orama Cloud for 3rd party search solution.
|
|
243
197
|
|
|
244
198
|
See https://fumadocs.dev/docs/headless/search/orama-cloud for integrating Orama Cloud to Fumadocs.`;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
fs3.unlink(path2.join(appDir, "app/api/search/route.ts")).catch(() => null),
|
|
279
|
-
writeFile(path2.join(appDir, "app/static.json/route.ts"), route.next)
|
|
280
|
-
]);
|
|
281
|
-
} else {
|
|
282
|
-
await Promise.all([
|
|
283
|
-
fs3.unlink(path2.join(appDir, "pages/api/search.ts")).catch(() => null),
|
|
284
|
-
writeFile(path2.join(appDir, "pages/static.json.ts"), route.waku)
|
|
285
|
-
]);
|
|
286
|
-
}
|
|
287
|
-
const filePath = {
|
|
288
|
-
"+next+fuma-docs-mdx": ".next/server/app/static.json.body",
|
|
289
|
-
"tanstack-start": ".output/public/static.json",
|
|
290
|
-
"tanstack-start-spa": "dist/client/static.json",
|
|
291
|
-
"react-router": "build/client/static.json",
|
|
292
|
-
"react-router-spa": "build/client/static.json",
|
|
293
|
-
waku: "dist/public/static.json"
|
|
294
|
-
}[template.value];
|
|
295
|
-
await writeFile(
|
|
296
|
-
path2.join(dest, "scripts/sync-content.ts"),
|
|
297
|
-
`import { type OramaDocument, sync } from 'fumadocs-core/search/orama-cloud';
|
|
199
|
+
},
|
|
200
|
+
async afterWrite() {
|
|
201
|
+
const { dest, appDir, template } = this;
|
|
202
|
+
await copy(path.join(sourceDir, "template/+orama-cloud/@root"), dest);
|
|
203
|
+
await copy(path.join(sourceDir, "template/+orama-cloud/@app"), appDir);
|
|
204
|
+
await rootProvider(this, (mod) => mod.addSearchDialog("@/components/search"));
|
|
205
|
+
if (template.value === "tanstack-start") await tanstackStartRoutes(this, (mod) => {
|
|
206
|
+
mod.addRoute({
|
|
207
|
+
path: "static[.]json.ts",
|
|
208
|
+
route: "/static.json",
|
|
209
|
+
code: route.tanstack,
|
|
210
|
+
prerender: true
|
|
211
|
+
});
|
|
212
|
+
mod.removeRoute({
|
|
213
|
+
path: "api/search.ts",
|
|
214
|
+
route: "/api/search"
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
else if (template.value.startsWith("react-router")) await reactRouterRoutes(this, (mod) => {
|
|
218
|
+
mod.addRoute("static.json", "routes/static.ts", route["react-router"]);
|
|
219
|
+
mod.removeRoute("api/search");
|
|
220
|
+
});
|
|
221
|
+
else if (template.value.startsWith("+next")) await Promise.all([fs.unlink(path.join(appDir, "app/api/search/route.ts")).catch(() => null), writeFile(path.join(appDir, "app/static.json/route.ts"), route.next)]);
|
|
222
|
+
else await Promise.all([fs.unlink(path.join(appDir, "pages/api/search.ts")).catch(() => null), writeFile(path.join(appDir, "pages/static.json.ts"), route.waku)]);
|
|
223
|
+
const filePath = {
|
|
224
|
+
"+next+fuma-docs-mdx": ".next/server/app/static.json.body",
|
|
225
|
+
"tanstack-start": ".output/public/static.json",
|
|
226
|
+
"tanstack-start-spa": "dist/client/static.json",
|
|
227
|
+
"react-router": "build/client/static.json",
|
|
228
|
+
"react-router-spa": "build/client/static.json",
|
|
229
|
+
waku: "dist/public/static.json"
|
|
230
|
+
}[template.value];
|
|
231
|
+
await writeFile(path.join(dest, "scripts/sync-content.ts"), `import { type OramaDocument, sync } from 'fumadocs-core/search/orama-cloud';
|
|
298
232
|
import * as fs from 'node:fs/promises';
|
|
299
233
|
import { OramaCloud } from '@orama/core';
|
|
300
234
|
|
|
@@ -318,25 +252,24 @@ async function main() {
|
|
|
318
252
|
console.log(\`search updated: \${records.length} records\`);
|
|
319
253
|
}
|
|
320
254
|
|
|
321
|
-
void main();`
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
};
|
|
255
|
+
void main();`);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
325
258
|
}
|
|
326
|
-
|
|
327
|
-
|
|
259
|
+
const route = {
|
|
260
|
+
next: `import { exportSearchIndexes } from '@/lib/export-search-indexes';
|
|
328
261
|
|
|
329
262
|
export const revalidate = false;
|
|
330
263
|
|
|
331
264
|
export async function GET() {
|
|
332
265
|
return Response.json(await exportSearchIndexes());
|
|
333
266
|
}`,
|
|
334
|
-
|
|
267
|
+
"react-router": `import { exportSearchIndexes } from '@/lib/export-search-indexes';
|
|
335
268
|
|
|
336
269
|
export async function loader() {
|
|
337
270
|
return Response.json(await exportSearchIndexes());
|
|
338
271
|
}`,
|
|
339
|
-
|
|
272
|
+
tanstack: `import { createFileRoute } from '@tanstack/react-router';
|
|
340
273
|
import { exportSearchIndexes } from '@/lib/export-search-indexes';
|
|
341
274
|
|
|
342
275
|
export const Route = createFileRoute('/static.json')({
|
|
@@ -346,7 +279,7 @@ export const Route = createFileRoute('/static.json')({
|
|
|
346
279
|
},
|
|
347
280
|
},
|
|
348
281
|
});`,
|
|
349
|
-
|
|
282
|
+
waku: `import { exportSearchIndexes } from '@/lib/export-search-indexes';
|
|
350
283
|
|
|
351
284
|
export async function GET() {
|
|
352
285
|
return Response.json(await exportSearchIndexes());
|
|
@@ -356,6 +289,7 @@ export const getConfig = () => ({
|
|
|
356
289
|
render: 'static',
|
|
357
290
|
});`
|
|
358
291
|
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
};
|
|
292
|
+
|
|
293
|
+
//#endregion
|
|
294
|
+
export { oramaCloud };
|
|
295
|
+
//# sourceMappingURL=orama-cloud.js.map
|