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.
Files changed (70) hide show
  1. package/dist/bin.d.ts +1 -1
  2. package/dist/bin.js +155 -206
  3. package/dist/bin.js.map +1 -0
  4. package/dist/constants-CReWPhck.js +150 -0
  5. package/dist/constants-CReWPhck.js.map +1 -0
  6. package/dist/index-CC4EFQ5p.d.ts +67 -0
  7. package/dist/index-CC4EFQ5p.d.ts.map +1 -0
  8. package/dist/index.d.ts +2 -63
  9. package/dist/index.js +4 -7
  10. package/dist/plugins/biome.base.d.ts +40 -45
  11. package/dist/plugins/biome.base.d.ts.map +1 -0
  12. package/dist/plugins/biome.base.js +37 -17
  13. package/dist/plugins/biome.base.js.map +1 -0
  14. package/dist/plugins/biome.d.ts +4 -2
  15. package/dist/plugins/biome.d.ts.map +1 -0
  16. package/dist/plugins/biome.js +30 -40
  17. package/dist/plugins/biome.js.map +1 -0
  18. package/dist/plugins/biome.next.d.ts +41 -49
  19. package/dist/plugins/biome.next.d.ts.map +1 -0
  20. package/dist/plugins/biome.next.js +43 -17
  21. package/dist/plugins/biome.next.js.map +1 -0
  22. package/dist/plugins/eslint.d.ts +4 -2
  23. package/dist/plugins/eslint.d.ts.map +1 -0
  24. package/dist/plugins/eslint.js +30 -33
  25. package/dist/plugins/eslint.js.map +1 -0
  26. package/dist/plugins/next-use-src.d.ts +5 -2
  27. package/dist/plugins/next-use-src.d.ts.map +1 -0
  28. package/dist/plugins/next-use-src.js +33 -35
  29. package/dist/plugins/next-use-src.js.map +1 -0
  30. package/dist/plugins/orama-cloud.d.ts +4 -2
  31. package/dist/plugins/orama-cloud.d.ts.map +1 -0
  32. package/dist/plugins/orama-cloud.js +210 -276
  33. package/dist/plugins/orama-cloud.js.map +1 -0
  34. package/dist/src-DWqRvlfn.js +89 -0
  35. package/dist/src-DWqRvlfn.js.map +1 -0
  36. package/package.json +19 -18
  37. package/template/+next+fuma-docs-mdx/app/docs/[[...slug]]/page.tsx +2 -9
  38. package/template/+next+fuma-docs-mdx/app/docs/layout.tsx +1 -1
  39. package/template/+next+fuma-docs-mdx/app/og/docs/[...slug]/route.tsx +2 -9
  40. package/template/+next+fuma-docs-mdx/package.json +2 -2
  41. package/template/+next+fuma-docs-mdx/source.config.ts +1 -6
  42. package/template/+orama-cloud/@app/components/search.tsx +1 -6
  43. package/template/react-router/app/docs/page.tsx +1 -6
  44. package/template/react-router/app/root.tsx +1 -3
  45. package/template/react-router/package.json +6 -6
  46. package/template/react-router/tsconfig.json +1 -6
  47. package/template/react-router-spa/app/components/search.tsx +1 -6
  48. package/template/react-router-spa/app/docs/page.tsx +2 -7
  49. package/template/react-router-spa/app/root.tsx +1 -3
  50. package/template/react-router-spa/package.json +6 -6
  51. package/template/react-router-spa/tsconfig.json +1 -6
  52. package/template/tanstack-start/content/docs/index.mdx +1 -4
  53. package/template/tanstack-start/package.json +4 -4
  54. package/template/tanstack-start/src/components/not-found.tsx +2 -2
  55. package/template/tanstack-start/src/routes/__root.tsx +1 -6
  56. package/template/tanstack-start/src/routes/docs/$.tsx +1 -6
  57. package/template/tanstack-start/src/routes/index.tsx +1 -3
  58. package/template/tanstack-start-spa/content/docs/index.mdx +1 -4
  59. package/template/tanstack-start-spa/package.json +5 -5
  60. package/template/tanstack-start-spa/src/components/not-found.tsx +2 -2
  61. package/template/tanstack-start-spa/src/components/search.tsx +1 -6
  62. package/template/tanstack-start-spa/src/routes/__root.tsx +1 -6
  63. package/template/tanstack-start-spa/src/routes/docs/$.tsx +2 -7
  64. package/template/waku/package.json +4 -4
  65. package/template/waku/src/pages/docs/[...slugs].tsx +2 -9
  66. package/template/waku/src/pages/docs/_layout.tsx +1 -1
  67. package/dist/chunk-BEZTHMLF.js +0 -51
  68. package/dist/chunk-CYYUEPDV.js +0 -179
  69. package/dist/chunk-JCFTHRDR.js +0 -50
  70. package/dist/chunk-Y54WH7LQ.js +0 -130
@@ -1,39 +1,37 @@
1
- // src/plugins/next-use-src.ts
2
- import path from "path";
3
- import fs from "fs/promises";
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
- return {
6
- template(info) {
7
- if (info.value !== "+next+fuma-docs-mdx") return;
8
- return {
9
- ...info,
10
- appDir: "src",
11
- rename: (file) => {
12
- if (path.basename(file) === "mdx-components.tsx" || isRelative(path.join(this.dest, "app"), file) || isRelative(path.join(this.dest, "lib"), file)) {
13
- return path.join(this.dest, "src", path.relative(this.dest, file));
14
- }
15
- return file;
16
- }
17
- };
18
- },
19
- // update tsconfig.json for src dir
20
- async afterWrite() {
21
- if (this.template.value !== "+next+fuma-docs-mdx") return;
22
- const tsconfigPath = path.join(this.dest, "tsconfig.json");
23
- const content = (await fs.readFile(tsconfigPath)).toString();
24
- const config = JSON.parse(content);
25
- if (config.compilerOptions?.paths) {
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
- return !path.relative(dir, file).startsWith(`..${path.sep}`);
32
+ return !path.relative(dir, file).startsWith(`..${path.sep}`);
36
33
  }
37
- export {
38
- nextUseSrc
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 '../index.js';
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
- copy,
3
- depVersions,
4
- pick,
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
- // src/plugins/orama-cloud.ts
10
- import path2 from "path";
11
- import fs3 from "fs/promises";
12
-
13
- // src/transform/shared.ts
14
- import { IndentationText, Project, QuoteKind } from "ts-morph";
15
- import fs from "fs/promises";
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
- return new Function(`return ${v}`)();
15
+ return new Function(`return ${v}`)();
29
16
  }
30
17
 
31
- // src/transform/index.ts
32
- import path from "path";
33
-
34
- // src/transform/react-router.ts
35
- import {
36
- ts
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
- const methodBody = getPrerenderMethod(sourceFile)?.getBody();
41
- if (!methodBody) return;
42
- const initializer = methodBody.getDescendantsOfKind(SyntaxKind.VariableDeclaration).find((item) => item.getName() === array)?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression);
43
- if (!initializer) return;
44
- for (const element of initializer.getElements()) {
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
- modifyReactRouterRoutes(sourceFile, (arr) => {
52
- for (const { path: path3, entry } of routes) {
53
- arr.addElement(`route('${path3}', '${entry}')`);
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
- modifyReactRouterRoutes(sourceFile, (arr) => {
59
- for (const element of arr.getElements()) {
60
- if (!element.isKind(SyntaxKind.CallExpression) || element.getFirstChildByKind(SyntaxKind.Identifier)?.getText() !== "route")
61
- continue;
62
- const args = element.getArguments();
63
- if (filter({
64
- path: getCodeValue(args[0].getText()),
65
- entry: getCodeValue(args[1].getText())
66
- }))
67
- continue;
68
- arr.removeElement(element);
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
- const initializer = sourceFile.getDefaultExportSymbol()?.getValueDeclaration()?.getFirstDescendantByKind(SyntaxKind.ArrayLiteralExpression);
74
- if (initializer) mod(initializer);
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
- return sourceFile.getDefaultExportSymbol()?.getValueDeclaration()?.getFirstDescendantByKind(SyntaxKind.ObjectLiteralExpression)?.getProperty("prerender")?.asKind(SyntaxKind.MethodDeclaration) ?? null;
63
+ return sourceFile.getDefaultExportSymbol()?.getValueDeclaration()?.getFirstDescendantByKind(SyntaxKind$1.ObjectLiteralExpression)?.getProperty("prerender")?.asKind(SyntaxKind$1.MethodDeclaration) ?? null;
78
64
  }
79
65
 
80
- // src/transform/index.ts
81
- import fs2 from "fs/promises";
82
-
83
- // src/transform/tanstack-start.ts
84
- import { SyntaxKind as SyntaxKind2 } from "ts-morph";
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
- const optionsArg = getTanstackStartCall(sourceFile)?.getArguments()[0]?.asKind(SyntaxKind2.ObjectLiteralExpression);
87
- if (!optionsArg) {
88
- return;
89
- }
90
- const pagesProperty = optionsArg.getProperty("pages")?.asKind(SyntaxKind2.PropertyAssignment);
91
- function toItem(path3) {
92
- return `{ path: '${path3}' }`;
93
- }
94
- if (pagesProperty) {
95
- const initializer = pagesProperty.getInitializerIfKindOrThrow(
96
- SyntaxKind2.ArrayLiteralExpression
97
- );
98
- const existingPaths = /* @__PURE__ */ new Set();
99
- for (const element of initializer.getElements()) {
100
- const value = element.asKind(SyntaxKind2.ObjectLiteralExpression)?.getProperty("path")?.asKind(SyntaxKind2.PropertyAssignment)?.getInitializer()?.getText();
101
- if (value) {
102
- existingPaths.add(getCodeValue(value));
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
- const pluginsProperty = sourceFile.getDefaultExportSymbol()?.getValueDeclaration()?.getFirstDescendantByKind(SyntaxKind2.ObjectLiteralExpression)?.getProperty("plugins")?.getFirstChildByKind(SyntaxKind2.ArrayLiteralExpression);
119
- if (!pluginsProperty) return;
120
- for (const element of pluginsProperty.getElements()) {
121
- const expression = element.asKind(SyntaxKind2.CallExpression);
122
- if (expression?.getFirstChildByKind(SyntaxKind2.Identifier)?.getText() === "tanstackStart") {
123
- return expression;
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
- // src/transform/index.ts
129
- import { StructureKind, SyntaxKind as SyntaxKind3 } from "ts-morph";
105
+ //#endregion
106
+ //#region src/transform/index.ts
130
107
  async function rootProvider({ appDir, template }, fn) {
131
- const file = await createSourceFile(
132
- path.join(appDir, template.rootProviderPath)
133
- );
134
- fn({
135
- addSearchDialog(specifier) {
136
- const elements = file.getDescendantsOfKind(SyntaxKind3.JsxElement);
137
- for (const element of elements) {
138
- const provider = element.getFirstChildByKind(
139
- SyntaxKind3.JsxOpeningElement
140
- );
141
- if (provider?.getTagNameNode().getText() !== "RootProvider") continue;
142
- if (provider.getAttributes().some(
143
- (attr) => attr.isKind(SyntaxKind3.JsxAttribute) && attr.getNameNode().getText() === "search"
144
- ))
145
- continue;
146
- provider.addAttribute({
147
- kind: StructureKind.JsxAttribute,
148
- name: "search",
149
- initializer: "{{ SearchDialog }}"
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
- const configFile = await createSourceFile(
163
- path.join(dest, "react-router.config.ts")
164
- );
165
- const routesFile = await createSourceFile(path.join(appDir, "routes.ts"));
166
- const tasks = [];
167
- function normalizePath(v) {
168
- return v.split("/").filter(Boolean).join("/");
169
- }
170
- fn({
171
- addRoute: (p, entry, code) => {
172
- addReactRouterRoute(routesFile, [{ path: p, entry }]);
173
- if (code) {
174
- tasks.push(fs2.writeFile(path.join(appDir, entry), code));
175
- }
176
- },
177
- removeRoute: (p) => {
178
- const normalizedPath = normalizePath(p);
179
- filterReactRouterRoute(routesFile, (item) => {
180
- if (normalizePath(item.path) !== normalizedPath) return true;
181
- tasks.push(fs2.unlink(path.join(appDir, item.entry)).catch(() => null));
182
- return false;
183
- });
184
- filterReactRouterPrerenderArray(
185
- configFile,
186
- "excluded",
187
- (item) => normalizePath(item) !== normalizedPath
188
- );
189
- filterReactRouterPrerenderArray(
190
- configFile,
191
- "paths",
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
- const configFile = await createSourceFile(path.join(dest, "vite.config.ts"));
200
- const tasks = [];
201
- fn({
202
- addRoute(options) {
203
- if (options.code) {
204
- tasks.push(
205
- fs2.writeFile(path.join(appDir, "routes", options.path), options.code)
206
- );
207
- }
208
- if (options.prerender) {
209
- addTanstackPrerender(configFile, [options.route]);
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
- // src/plugins/orama-cloud.ts
176
+ //#endregion
177
+ //#region src/plugins/orama-cloud.ts
222
178
  function oramaCloud() {
223
- return {
224
- packageJson(packageJson) {
225
- return {
226
- ...packageJson,
227
- scripts: {
228
- ...packageJson.scripts,
229
- build: `${packageJson.scripts.build} && bun scripts/sync-content.ts`
230
- },
231
- dependencies: {
232
- ...packageJson.dependencies,
233
- ...pick(depVersions, ["@orama/core"])
234
- }
235
- };
236
- },
237
- readme(content) {
238
- return `${content}
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
- async afterWrite() {
247
- const { dest, appDir, template } = this;
248
- await copy(path2.join(sourceDir, "template/+orama-cloud/@root"), dest);
249
- await copy(path2.join(sourceDir, "template/+orama-cloud/@app"), appDir);
250
- await rootProvider(
251
- this,
252
- (mod) => mod.addSearchDialog("@/components/search")
253
- );
254
- if (template.value === "tanstack-start") {
255
- await tanstackStartRoutes(this, (mod) => {
256
- mod.addRoute({
257
- path: "static[.]json.ts",
258
- route: "/static.json",
259
- code: route.tanstack,
260
- prerender: true
261
- });
262
- mod.removeRoute({
263
- path: "api/search.ts",
264
- route: "/api/search"
265
- });
266
- });
267
- } else if (template.value.startsWith("react-router")) {
268
- await reactRouterRoutes(this, (mod) => {
269
- mod.addRoute(
270
- "static.json",
271
- "routes/static.ts",
272
- route["react-router"]
273
- );
274
- mod.removeRoute("api/search");
275
- });
276
- } else if (template.value.startsWith("+next")) {
277
- await Promise.all([
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
- var route = {
327
- next: `import { exportSearchIndexes } from '@/lib/export-search-indexes';
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
- "react-router": `import { exportSearchIndexes } from '@/lib/export-search-indexes';
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
- tanstack: `import { createFileRoute } from '@tanstack/react-router';
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
- waku: `import { exportSearchIndexes } from '@/lib/export-search-indexes';
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
- export {
360
- oramaCloud
361
- };
292
+
293
+ //#endregion
294
+ export { oramaCloud };
295
+ //# sourceMappingURL=orama-cloud.js.map