fumapress 0.2.2 → 0.2.4
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/css/generated.css +103 -0
- package/dist/adapters/mdx.d.ts +12 -0
- package/dist/adapters/mdx.js +37 -0
- package/dist/components/flexsearch-static.js +24 -0
- package/dist/components/orama-search-static.js +34 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +36 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/layouts/docs.d.ts +35 -0
- package/dist/layouts/docs.js +85 -0
- package/dist/layouts/home.d.ts +28 -0
- package/dist/layouts/home.js +34 -0
- package/dist/layouts/root.d.ts +10 -0
- package/dist/layouts/root.js +38 -0
- package/dist/lib/fs.js +18 -0
- package/dist/lib/shared.d.ts +41 -0
- package/dist/lib/shared.js +63 -0
- package/dist/lib/types.d.ts +33 -0
- package/dist/lib/vitefu.js +179 -0
- package/dist/plugins/flexsearch.d.ts +14 -0
- package/dist/plugins/flexsearch.js +35 -0
- package/dist/plugins/llms.txt.d.ts +11 -0
- package/dist/plugins/llms.txt.js +72 -0
- package/dist/plugins/orama-search.d.ts +14 -0
- package/dist/plugins/orama-search.js +35 -0
- package/dist/plugins/takumi.d.ts +16 -0
- package/dist/plugins/takumi.js +79 -0
- package/dist/router.d.ts +11 -0
- package/dist/router.js +133 -0
- package/dist/vite.d.ts +6 -0
- package/dist/vite.js +45 -0
- package/package.json +10 -16
package/dist/router.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { parseConfig } from "./lib/shared.js";
|
|
2
|
+
import * as waku from "waku";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import { unstable_redirect } from "waku/router/server";
|
|
5
|
+
//#region src/router.ts
|
|
6
|
+
function createRouter(userConfig, routerOptions) {
|
|
7
|
+
async function init() {
|
|
8
|
+
const context = parseConfig(userConfig);
|
|
9
|
+
for (const plugin of context.plugins) plugin.init?.call(context);
|
|
10
|
+
const layouts = {
|
|
11
|
+
...userConfig.layouts,
|
|
12
|
+
...routerOptions
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
context,
|
|
16
|
+
root: layouts?.root ?? (await import("./layouts/root.js")).createRootLayout(),
|
|
17
|
+
page: layouts.page ?? (await import("./layouts/docs.js")).createDocsLayout(),
|
|
18
|
+
notFound: layouts.notFound ?? (await import("fumadocs-ui/layouts/home/not-found")).DefaultNotFound
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const createPages = (base, createPagesOptions) => {
|
|
22
|
+
return waku.createPages(async (_fns) => {
|
|
23
|
+
const { context, ...layouts } = await init();
|
|
24
|
+
const fns = {
|
|
25
|
+
..._fns,
|
|
26
|
+
createApiIsomorphic(config) {
|
|
27
|
+
if (config.render === "static") _fns.createApi({
|
|
28
|
+
render: "static",
|
|
29
|
+
method: "GET",
|
|
30
|
+
staticPaths: config.staticPaths,
|
|
31
|
+
path: config.path,
|
|
32
|
+
handler: config.handler
|
|
33
|
+
});
|
|
34
|
+
else _fns.createApi({
|
|
35
|
+
render: "dynamic",
|
|
36
|
+
path: config.path,
|
|
37
|
+
handlers: { GET: config.handler }
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
await base(fns);
|
|
42
|
+
for (const plugin of context.plugins) await plugin.createPages?.call(context, fns);
|
|
43
|
+
const defaultRenderMode = context.mode === "dynamic" ? "dynamic" : "static";
|
|
44
|
+
if (context.i18nConfig) {
|
|
45
|
+
fns.createRoot({
|
|
46
|
+
render: defaultRenderMode,
|
|
47
|
+
component({ children }) {
|
|
48
|
+
return children;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
fns.createLayout({
|
|
52
|
+
render: defaultRenderMode,
|
|
53
|
+
path: "/[lang]",
|
|
54
|
+
component({ children, lang }) {
|
|
55
|
+
return createElement(layouts.root, {
|
|
56
|
+
lang,
|
|
57
|
+
children,
|
|
58
|
+
...context
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
fns.createPage({
|
|
63
|
+
render: defaultRenderMode,
|
|
64
|
+
path: "/[lang]/[...slugs]",
|
|
65
|
+
staticPaths: (await context.getLoader()).getPages().map((page) => [page.locale, ...page.slugs]),
|
|
66
|
+
component({ slugs, lang }) {
|
|
67
|
+
return createElement(layouts.page, {
|
|
68
|
+
lang,
|
|
69
|
+
slugs,
|
|
70
|
+
...context
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
fns.createPage({
|
|
75
|
+
render: defaultRenderMode,
|
|
76
|
+
path: "/[lang]/404",
|
|
77
|
+
staticPaths: Object.keys(context.i18nConfig.languages),
|
|
78
|
+
component({ lang }) {
|
|
79
|
+
return createElement(layouts.notFound, {
|
|
80
|
+
lang,
|
|
81
|
+
...context
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (context.mode !== "static") fns.createPage({
|
|
86
|
+
render: "dynamic",
|
|
87
|
+
path: "/404",
|
|
88
|
+
component() {
|
|
89
|
+
unstable_redirect(`/${context.i18nConfig.defaultLanguage}`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
fns.createRoot({
|
|
94
|
+
render: defaultRenderMode,
|
|
95
|
+
component({ children }) {
|
|
96
|
+
return createElement(layouts.root, {
|
|
97
|
+
children,
|
|
98
|
+
...context
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
fns.createPage({
|
|
103
|
+
render: defaultRenderMode,
|
|
104
|
+
path: "/[...slugs]",
|
|
105
|
+
staticPaths: (await context.getLoader()).getPages().map((page) => page.slugs),
|
|
106
|
+
component({ slugs }) {
|
|
107
|
+
return createElement(layouts.page, {
|
|
108
|
+
slugs,
|
|
109
|
+
...context
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
fns.createPage({
|
|
114
|
+
render: defaultRenderMode,
|
|
115
|
+
staticPaths: [],
|
|
116
|
+
path: "/404",
|
|
117
|
+
component() {
|
|
118
|
+
return createElement(layouts.notFound, context);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}, createPagesOptions);
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
extend: createPages,
|
|
127
|
+
createPages() {
|
|
128
|
+
return createPages(() => null);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { createRouter };
|
package/dist/vite.d.ts
ADDED
package/dist/vite.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { crawlFrameworkPkgs } from "./lib/vitefu.js";
|
|
2
|
+
//#region src/vite.ts
|
|
3
|
+
function press() {
|
|
4
|
+
return pressCore();
|
|
5
|
+
}
|
|
6
|
+
function pressCore() {
|
|
7
|
+
return {
|
|
8
|
+
name: "fumapress:core",
|
|
9
|
+
async config(_, { command }) {
|
|
10
|
+
const out = await crawlFrameworkPkgs({
|
|
11
|
+
root: process.cwd(),
|
|
12
|
+
isBuild: command === "build",
|
|
13
|
+
isFrameworkPkgByName(pkgName) {
|
|
14
|
+
if (pkgName.startsWith("@fumapress/") || pkgName.startsWith("@fumadocs/") || pkgName.startsWith("fumadocs-") || pkgName.startsWith("fumapress-") || pkgName === "fumapress") return true;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
ssr: {
|
|
19
|
+
noExternal: out.ssr.noExternal,
|
|
20
|
+
external: ["@takumi-rs/image-response"]
|
|
21
|
+
},
|
|
22
|
+
optimizeDeps: out.optimizeDeps
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
async resolveId(source, _importer, options) {
|
|
26
|
+
if (source === "virtual:fumapress-core/config") return this.resolve("/press.config", void 0, options);
|
|
27
|
+
if (source === "virtual:root.css?inline") return await this.resolve(`/src/app.css?inline`) ?? await this.resolve(`fumapress/css/default.css?inline`);
|
|
28
|
+
},
|
|
29
|
+
async load(id) {
|
|
30
|
+
if (id === "\0virtual:vite-rsc-waku/server-entry-inner") return getManagedServerEntry();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function getManagedServerEntry() {
|
|
35
|
+
return `import adapter from 'waku/adapters/default';
|
|
36
|
+
import pressConfig from 'virtual:fumapress-core/config';
|
|
37
|
+
import { createRouter } from 'fumapress/router';
|
|
38
|
+
|
|
39
|
+
const router = createRouter(pressConfig);
|
|
40
|
+
|
|
41
|
+
export default adapter(router.createPages());
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { press as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumapress",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "An opinionated docs framework powered by Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -40,32 +40,29 @@
|
|
|
40
40
|
"@orama/orama": "^3.1.18",
|
|
41
41
|
"@takumi-rs/image-response": "^1.1.2",
|
|
42
42
|
"flexsearch": "^0.8.212",
|
|
43
|
-
"fumadocs-core": "^16.8.
|
|
44
|
-
"fumadocs-ui": "^16.8.
|
|
45
|
-
"
|
|
46
|
-
"
|
|
43
|
+
"fumadocs-core": "^16.8.10",
|
|
44
|
+
"fumadocs-ui": "^16.8.10",
|
|
45
|
+
"tailwind-merge": "^3.5.0",
|
|
46
|
+
"vite": "^8.0.11",
|
|
47
|
+
"waku": "1.0.0-alpha.10"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@tailwindcss/oxide": "^4.3.0",
|
|
50
51
|
"@types/mdx": "^2.0.13",
|
|
51
|
-
"@types/node": "^25.
|
|
52
|
+
"@types/node": "^25.7.0",
|
|
52
53
|
"@types/react": "^19.2.14",
|
|
53
|
-
"fumadocs-mdx": "^15.0.
|
|
54
|
+
"fumadocs-mdx": "^15.0.4",
|
|
54
55
|
"react": "^19.2.6",
|
|
55
56
|
"react-dom": "^19.2.6",
|
|
56
57
|
"tsdown": "0.22.0",
|
|
57
|
-
"typescript": "^6.0.3"
|
|
58
|
-
"vite": "^8.0.11",
|
|
59
|
-
"waku": "1.0.0-alpha.10"
|
|
58
|
+
"typescript": "^6.0.3"
|
|
60
59
|
},
|
|
61
60
|
"peerDependencies": {
|
|
62
61
|
"@types/mdx": "*",
|
|
63
62
|
"@types/react": "*",
|
|
64
63
|
"fumadocs-mdx": "^15.0.0",
|
|
65
64
|
"react": "^19.2.0",
|
|
66
|
-
"react-dom": "^19.2.0"
|
|
67
|
-
"vite": "8.x.x",
|
|
68
|
-
"waku": "1.0.0-alpha.9"
|
|
65
|
+
"react-dom": "^19.2.0"
|
|
69
66
|
},
|
|
70
67
|
"peerDependenciesMeta": {
|
|
71
68
|
"@types/mdx": {
|
|
@@ -76,9 +73,6 @@
|
|
|
76
73
|
},
|
|
77
74
|
"@types/react": {
|
|
78
75
|
"optional": true
|
|
79
|
-
},
|
|
80
|
-
"vite": {
|
|
81
|
-
"optional": true
|
|
82
76
|
}
|
|
83
77
|
},
|
|
84
78
|
"scripts": {
|