fumapress 0.2.1 → 0.2.3
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/LICENSE +1 -1
- package/css/default.css +4 -4
- package/css/preset.css +1 -1
- package/package.json +17 -19
- package/css/generated.css +0 -99
- package/dist/adapters/mdx.d.ts +0 -6
- package/dist/adapters/mdx.js +0 -39
- package/dist/components/flexsearch-static.js +0 -24
- package/dist/components/orama-search-static.js +0 -34
- package/dist/config.d.ts +0 -57
- package/dist/config.js +0 -13
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -2
- package/dist/layouts/docs.d.ts +0 -29
- package/dist/layouts/docs.js +0 -67
- package/dist/layouts/home.d.ts +0 -26
- package/dist/layouts/home.js +0 -34
- package/dist/layouts/root.d.ts +0 -7
- package/dist/layouts/root.js +0 -35
- package/dist/lib/fs.js +0 -18
- package/dist/lib/shared.d.ts +0 -39
- package/dist/lib/shared.js +0 -64
- package/dist/lib/types.d.ts +0 -33
- package/dist/plugins/flexsearch.d.ts +0 -14
- package/dist/plugins/flexsearch.js +0 -36
- package/dist/plugins/llms.txt.d.ts +0 -11
- package/dist/plugins/llms.txt.js +0 -72
- package/dist/plugins/orama-search.d.ts +0 -14
- package/dist/plugins/orama-search.js +0 -35
- package/dist/plugins/takumi.d.ts +0 -16
- package/dist/plugins/takumi.js +0 -78
- package/dist/router.d.ts +0 -26
- package/dist/router.js +0 -129
- package/dist/vite.d.ts +0 -6
- package/dist/vite.js +0 -45
package/LICENSE
CHANGED
package/css/default.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import
|
|
2
|
-
@import
|
|
3
|
-
@import
|
|
4
|
-
@import
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@import "fumadocs-ui/css/neutral.css";
|
|
3
|
+
@import "fumadocs-ui/css/preset.css";
|
|
4
|
+
@import "./preset.css";
|
package/css/preset.css
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumapress",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "An opinionated docs framework powered by Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
7
7
|
"Fumadocs"
|
|
8
8
|
],
|
|
9
|
-
"homepage": "https://fumadocs.dev",
|
|
9
|
+
"homepage": "https://press.fumadocs.dev",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"author": "Fuma Nama",
|
|
12
|
-
"repository": "github:fuma-nama/
|
|
12
|
+
"repository": "github:fuma-nama/fumapress",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
|
-
"css"
|
|
15
|
+
"css",
|
|
16
|
+
"LICENSE.vitefu"
|
|
16
17
|
],
|
|
17
18
|
"type": "module",
|
|
18
19
|
"sideEffects": false,
|
|
@@ -39,41 +40,38 @@
|
|
|
39
40
|
"@orama/orama": "^3.1.18",
|
|
40
41
|
"@takumi-rs/image-response": "^1.1.2",
|
|
41
42
|
"flexsearch": "^0.8.212",
|
|
42
|
-
"
|
|
43
|
+
"fumadocs-core": "^16.8.10",
|
|
44
|
+
"fumadocs-ui": "^16.8.10",
|
|
43
45
|
"tailwind-merge": "^3.5.0",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"fumadocs-ui": "16.8.9"
|
|
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",
|
|
54
|
+
"fumadocs-mdx": "^15.0.4",
|
|
53
55
|
"react": "^19.2.6",
|
|
54
56
|
"react-dom": "^19.2.6",
|
|
55
57
|
"tsdown": "0.22.0",
|
|
56
|
-
"typescript": "^6.0.3"
|
|
57
|
-
"vite": "^8.0.11",
|
|
58
|
-
"waku": "1.0.0-alpha.10",
|
|
59
|
-
"fumadocs-mdx": "15.0.2"
|
|
58
|
+
"typescript": "^6.0.3"
|
|
60
59
|
},
|
|
61
60
|
"peerDependencies": {
|
|
61
|
+
"@types/mdx": "*",
|
|
62
62
|
"@types/react": "*",
|
|
63
63
|
"fumadocs-mdx": "^15.0.0",
|
|
64
64
|
"react": "^19.2.0",
|
|
65
|
-
"react-dom": "^19.2.0"
|
|
66
|
-
"vite": "8.x.x",
|
|
67
|
-
"waku": "1.0.0-alpha.9"
|
|
65
|
+
"react-dom": "^19.2.0"
|
|
68
66
|
},
|
|
69
67
|
"peerDependenciesMeta": {
|
|
70
|
-
"
|
|
68
|
+
"@types/mdx": {
|
|
71
69
|
"optional": true
|
|
72
70
|
},
|
|
73
|
-
"
|
|
71
|
+
"fumadocs-mdx": {
|
|
74
72
|
"optional": true
|
|
75
73
|
},
|
|
76
|
-
"
|
|
74
|
+
"@types/react": {
|
|
77
75
|
"optional": true
|
|
78
76
|
}
|
|
79
77
|
},
|
package/css/generated.css
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
@source inline("@orama/orama");
|
|
2
|
-
@source inline("absolutePath");
|
|
3
|
-
@source inline("adapter");
|
|
4
|
-
@source inline("as");
|
|
5
|
-
@source inline("async");
|
|
6
|
-
@source inline("await");
|
|
7
|
-
@source inline("body");
|
|
8
|
-
@source inline("border-b");
|
|
9
|
-
@source inline("className");
|
|
10
|
-
@source inline("client");
|
|
11
|
-
@source inline("const");
|
|
12
|
-
@source inline("core:docs-layout");
|
|
13
|
-
@source inline("core:home-layout");
|
|
14
|
-
@source inline("core:provider");
|
|
15
|
-
@source inline("core:render-body");
|
|
16
|
-
@source inline("core:render-toc");
|
|
17
|
-
@source inline("create");
|
|
18
|
-
@source inline("createDocsLayout");
|
|
19
|
-
@source inline("createHomeLayout");
|
|
20
|
-
@source inline("createRootLayout");
|
|
21
|
-
@source inline("data");
|
|
22
|
-
@source inline("data-version");
|
|
23
|
-
@source inline("default");
|
|
24
|
-
@source inline("empty");
|
|
25
|
-
@source inline("en");
|
|
26
|
-
@source inline("english");
|
|
27
|
-
@source inline("export");
|
|
28
|
-
@source inline("extends");
|
|
29
|
-
@source inline("flex");
|
|
30
|
-
@source inline("flex-col");
|
|
31
|
-
@source inline("flex-row");
|
|
32
|
-
@source inline("flexsearchStaticClient");
|
|
33
|
-
@source inline("for");
|
|
34
|
-
@source inline("from");
|
|
35
|
-
@source inline("fumadocs-core/source");
|
|
36
|
-
@source inline("fumadocs-core/toc");
|
|
37
|
-
@source inline("function");
|
|
38
|
-
@source inline("gap-2");
|
|
39
|
-
@source inline("githubUrl");
|
|
40
|
-
@source inline("hook");
|
|
41
|
-
@source inline("hooks");
|
|
42
|
-
@source inline("i18n");
|
|
43
|
-
@source inline("if");
|
|
44
|
-
@source inline("import");
|
|
45
|
-
@source inline("in");
|
|
46
|
-
@source inline("interface");
|
|
47
|
-
@source inline("isLoading");
|
|
48
|
-
@source inline("items");
|
|
49
|
-
@source inline("items-center");
|
|
50
|
-
@source inline("lang");
|
|
51
|
-
@source inline("language");
|
|
52
|
-
@source inline("layoutData");
|
|
53
|
-
@source inline("layoutProps");
|
|
54
|
-
@source inline("let");
|
|
55
|
-
@source inline("loaderConfig");
|
|
56
|
-
@source inline("locale");
|
|
57
|
-
@source inline("locales");
|
|
58
|
-
@source inline("markdownUrl");
|
|
59
|
-
@source inline("mb-0");
|
|
60
|
-
@source inline("min-h-screen");
|
|
61
|
-
@source inline("name");
|
|
62
|
-
@source inline("new");
|
|
63
|
-
@source inline("of");
|
|
64
|
-
@source inline("onSearchChange");
|
|
65
|
-
@source inline("option");
|
|
66
|
-
@source inline("page");
|
|
67
|
-
@source inline("pageProps");
|
|
68
|
-
@source inline("pb-6");
|
|
69
|
-
@source inline("providerProps");
|
|
70
|
-
@source inline("pt-2");
|
|
71
|
-
@source inline("query");
|
|
72
|
-
@source inline("r");
|
|
73
|
-
@source inline("react");
|
|
74
|
-
@source inline("render");
|
|
75
|
-
@source inline("renderCtx");
|
|
76
|
-
@source inline("renderPageMeta");
|
|
77
|
-
@source inline("renderRootMeta");
|
|
78
|
-
@source inline("result");
|
|
79
|
-
@source inline("return");
|
|
80
|
-
@source inline("root");
|
|
81
|
-
@source inline("schema");
|
|
82
|
-
@source inline("search");
|
|
83
|
-
@source inline("source");
|
|
84
|
-
@source inline("specify");
|
|
85
|
-
@source inline("static");
|
|
86
|
-
@source inline("string");
|
|
87
|
-
@source inline("styles");
|
|
88
|
-
@source inline("the");
|
|
89
|
-
@source inline("this");
|
|
90
|
-
@source inline("throw");
|
|
91
|
-
@source inline("toc");
|
|
92
|
-
@source inline("translations");
|
|
93
|
-
@source inline("tree");
|
|
94
|
-
@source inline("type");
|
|
95
|
-
@source inline("unknown");
|
|
96
|
-
@source inline("unstable_notFound");
|
|
97
|
-
@source inline("use");
|
|
98
|
-
@source inline("useDocsSearch");
|
|
99
|
-
@source inline("useI18n");
|
package/dist/adapters/mdx.d.ts
DELETED
package/dist/adapters/mdx.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
import defaultMdxComponents, { createRelativeLink } from "fumadocs-ui/mdx";
|
|
3
|
-
//#region src/adapters/mdx.ts
|
|
4
|
-
function fumadocsMdx() {
|
|
5
|
-
return {
|
|
6
|
-
async "core:get-text"(page) {
|
|
7
|
-
if (isAsyncEntry(page.data) || isSyncEntry(page.data)) return page.data.getText("processed");
|
|
8
|
-
},
|
|
9
|
-
async "core:get-structured-data"(page) {
|
|
10
|
-
if (isSyncEntry(page.data)) return page.data.structuredData;
|
|
11
|
-
if (isAsyncEntry(page.data)) return (await page.data.load()).structuredData;
|
|
12
|
-
},
|
|
13
|
-
async "core:render-body"(page) {
|
|
14
|
-
if (isSyncEntry(page.data)) return createElement(page.data.body, { components: {
|
|
15
|
-
...defaultMdxComponents,
|
|
16
|
-
a: createRelativeLink(await this.getLoader(), page)
|
|
17
|
-
} });
|
|
18
|
-
if (isAsyncEntry(page.data)) {
|
|
19
|
-
const { body } = await page.data.load();
|
|
20
|
-
return createElement(body, { components: {
|
|
21
|
-
...defaultMdxComponents,
|
|
22
|
-
a: createRelativeLink(await this.getLoader(), page)
|
|
23
|
-
} });
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
async "core:render-toc"(page) {
|
|
27
|
-
if (isSyncEntry(page.data)) return page.data.toc;
|
|
28
|
-
if (isAsyncEntry(page.data)) return (await page.data.load()).toc;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function isSyncEntry(v) {
|
|
33
|
-
return "info" in v && typeof v.info === "object" && "_exports" in v && typeof v._exports === "object";
|
|
34
|
-
}
|
|
35
|
-
function isAsyncEntry(v) {
|
|
36
|
-
return "info" in v && typeof v.info === "object" && "load" in v && typeof v.load === "function";
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
export { fumadocsMdx };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay } from "fumadocs-ui/components/dialog/search";
|
|
4
|
-
import { useDocsSearch } from "fumadocs-core/search/client";
|
|
5
|
-
import { flexsearchStaticClient } from "fumadocs-core/search/client/flexsearch-static";
|
|
6
|
-
import { useI18n } from "fumadocs-ui/contexts/i18n";
|
|
7
|
-
//#region src/components/flexsearch-static.tsx
|
|
8
|
-
function DefaultSearchDialog(props) {
|
|
9
|
-
const { locale } = useI18n();
|
|
10
|
-
const { search, setSearch, query } = useDocsSearch({ client: flexsearchStaticClient({ locale }) });
|
|
11
|
-
return /* @__PURE__ */ jsxs(SearchDialog, {
|
|
12
|
-
search,
|
|
13
|
-
onSearchChange: setSearch,
|
|
14
|
-
isLoading: query.isLoading,
|
|
15
|
-
...props,
|
|
16
|
-
children: [/* @__PURE__ */ jsx(SearchDialogOverlay, {}), /* @__PURE__ */ jsxs(SearchDialogContent, { children: [/* @__PURE__ */ jsxs(SearchDialogHeader, { children: [
|
|
17
|
-
/* @__PURE__ */ jsx(SearchDialogIcon, {}),
|
|
18
|
-
/* @__PURE__ */ jsx(SearchDialogInput, {}),
|
|
19
|
-
/* @__PURE__ */ jsx(SearchDialogClose, {})
|
|
20
|
-
] }), /* @__PURE__ */ jsx(SearchDialogList, { items: query.data !== "empty" ? query.data : null })] })]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { DefaultSearchDialog as default };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { SearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogOverlay } from "fumadocs-ui/components/dialog/search";
|
|
4
|
-
import { useDocsSearch } from "fumadocs-core/search/client";
|
|
5
|
-
import { useI18n } from "fumadocs-ui/contexts/i18n";
|
|
6
|
-
import { create } from "@orama/orama";
|
|
7
|
-
//#region src/components/orama-search-static.tsx
|
|
8
|
-
function initOrama() {
|
|
9
|
-
return create({
|
|
10
|
-
schema: { _: "string" },
|
|
11
|
-
language: "english"
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function DefaultSearchDialog(props) {
|
|
15
|
-
const { locale } = useI18n();
|
|
16
|
-
const { search, setSearch, query } = useDocsSearch({
|
|
17
|
-
type: "static",
|
|
18
|
-
initOrama,
|
|
19
|
-
locale
|
|
20
|
-
});
|
|
21
|
-
return /* @__PURE__ */ jsxs(SearchDialog, {
|
|
22
|
-
search,
|
|
23
|
-
onSearchChange: setSearch,
|
|
24
|
-
isLoading: query.isLoading,
|
|
25
|
-
...props,
|
|
26
|
-
children: [/* @__PURE__ */ jsx(SearchDialogOverlay, {}), /* @__PURE__ */ jsxs(SearchDialogContent, { children: [/* @__PURE__ */ jsxs(SearchDialogHeader, { children: [
|
|
27
|
-
/* @__PURE__ */ jsx(SearchDialogIcon, {}),
|
|
28
|
-
/* @__PURE__ */ jsx(SearchDialogInput, {}),
|
|
29
|
-
/* @__PURE__ */ jsx(SearchDialogClose, {})
|
|
30
|
-
] }), /* @__PURE__ */ jsx(SearchDialogList, { items: query.data !== "empty" ? query.data : null })] })]
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
export { DefaultSearchDialog as default };
|
package/dist/config.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "./lib/shared.js";
|
|
2
|
-
import { Adapter, Awaitable, ServerPlugin } from "./lib/types.js";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
|
-
import { TranslationsOption } from "fumadocs-ui/contexts/i18n";
|
|
5
|
-
import { LoaderConfig, LoaderOutput } from "fumadocs-core/source";
|
|
6
|
-
import { I18nConfig } from "fumadocs-core/i18n";
|
|
7
|
-
|
|
8
|
-
//#region src/config.d.ts
|
|
9
|
-
interface ConfigContext {
|
|
10
|
-
loaderConfig: LoaderConfig;
|
|
11
|
-
}
|
|
12
|
-
type BuildMode = 'static' | 'dynamic' | 'default';
|
|
13
|
-
interface Config<C extends ConfigContext = ConfigContext> {
|
|
14
|
-
/**
|
|
15
|
-
* - `static`: always prefer static, including search etc.
|
|
16
|
-
* - `dynamic`: always prefer dynamic.
|
|
17
|
-
* - `default`: only certain parts like search routes are dynamic.
|
|
18
|
-
*/
|
|
19
|
-
mode?: BuildMode;
|
|
20
|
-
/** the default content loader */
|
|
21
|
-
loader: LoaderOutput<C['loaderConfig']> | (() => Awaitable<LoaderOutput<C['loaderConfig']>>);
|
|
22
|
-
site?: SiteConfig;
|
|
23
|
-
plugins?: ServerPlugin[] | ((ctx: AppContext<C>) => ServerPlugin[]);
|
|
24
|
-
/** adapter for content sources, use `fumadocs-mdx` if not specified */
|
|
25
|
-
adapters?: Adapter[];
|
|
26
|
-
i18n?: I18nConfig$1;
|
|
27
|
-
meta?: {
|
|
28
|
-
/** render meta tags for any pages */root?: (this: AppContext<C>) => ReactNode; /** render meta tags for page */
|
|
29
|
-
page?: (this: AppContext<C>, page: C['loaderConfig']['page']) => ReactNode;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
interface I18nConfig$1 {
|
|
33
|
-
/** locale code -> language info */
|
|
34
|
-
languages: Record<string, {
|
|
35
|
-
displayName: string;
|
|
36
|
-
translations?: TranslationsOption;
|
|
37
|
-
}>;
|
|
38
|
-
defaultLanguage: string;
|
|
39
|
-
}
|
|
40
|
-
/** convert Fumapress i18n config to core i18n config */
|
|
41
|
-
declare function coreI18n(i18n: I18nConfig$1): I18nConfig;
|
|
42
|
-
interface SiteConfig {
|
|
43
|
-
name?: string;
|
|
44
|
-
git?: {
|
|
45
|
-
user: string;
|
|
46
|
-
repo: string;
|
|
47
|
-
branch: string; /** the root directory of git repo */
|
|
48
|
-
rootDir?: string;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
declare function defineConfig<C extends LoaderConfig>(config: Config<{
|
|
52
|
-
loaderConfig: C;
|
|
53
|
-
}>): Config<{
|
|
54
|
-
loaderConfig: C;
|
|
55
|
-
}>;
|
|
56
|
-
//#endregion
|
|
57
|
-
export { BuildMode, Config, ConfigContext, I18nConfig$1 as I18nConfig, SiteConfig, coreI18n, defineConfig };
|
package/dist/config.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/config.ts
|
|
2
|
-
/** convert Fumapress i18n config to core i18n config */
|
|
3
|
-
function coreI18n(i18n) {
|
|
4
|
-
return {
|
|
5
|
-
defaultLanguage: i18n.defaultLanguage,
|
|
6
|
-
languages: Object.keys(i18n.languages)
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
function defineConfig(config) {
|
|
10
|
-
return config;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { coreI18n, defineConfig };
|
package/dist/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BuildMode, Config, ConfigContext, I18nConfig, SiteConfig, coreI18n, defineConfig } from "./config.js";
|
|
2
|
-
import { AppContext, AppContextData } from "./lib/shared.js";
|
|
3
|
-
import { Adapter, ServerPlugin } from "./lib/types.js";
|
|
4
|
-
export { type Adapter, type AppContext, type AppContextData, BuildMode, Config, ConfigContext, I18nConfig, type ServerPlugin, SiteConfig, coreI18n, defineConfig };
|
package/dist/index.js
DELETED
package/dist/layouts/docs.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ConfigContext } from "../config.js";
|
|
2
|
-
import { Layouts } from "../router.js";
|
|
3
|
-
import { AppContext } from "../lib/shared.js";
|
|
4
|
-
import { Awaitable } from "../lib/types.js";
|
|
5
|
-
import { ReactNode } from "react";
|
|
6
|
-
import { DocsLayoutProps } from "fumadocs-ui/layouts/docs";
|
|
7
|
-
import { DocsPageProps } from "fumadocs-ui/layouts/docs/page";
|
|
8
|
-
import { Page } from "fumadocs-core/source";
|
|
9
|
-
|
|
10
|
-
//#region src/layouts/docs.d.ts
|
|
11
|
-
interface DocsLayoutOptions<C extends ConfigContext = ConfigContext> {
|
|
12
|
-
render?: (this: AppContext<C>, page: C['loaderConfig']['page']) => Awaitable<Partial<DocsLayoutRenderData>>;
|
|
13
|
-
}
|
|
14
|
-
interface DocsLayoutRenderData {
|
|
15
|
-
markdownUrl?: string;
|
|
16
|
-
body: ReactNode;
|
|
17
|
-
layoutProps: DocsLayoutProps;
|
|
18
|
-
pageProps?: DocsPageProps;
|
|
19
|
-
}
|
|
20
|
-
interface DocsLayoutContextData {
|
|
21
|
-
renderers?: ((this: {
|
|
22
|
-
page: Page;
|
|
23
|
-
}, data: DocsLayoutRenderData) => Awaitable<DocsLayoutRenderData>)[];
|
|
24
|
-
}
|
|
25
|
-
declare function createDocsLayout<C extends ConfigContext = ConfigContext>({
|
|
26
|
-
render
|
|
27
|
-
}?: DocsLayoutOptions<C>): Layouts<C>['page'];
|
|
28
|
-
//#endregion
|
|
29
|
-
export { DocsLayoutContextData, DocsLayoutOptions, DocsLayoutRenderData, createDocsLayout };
|
package/dist/layouts/docs.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { baseOptions, getGitHubFileUrl, renderPageMeta } from "../lib/shared.js";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { unstable_notFound } from "waku/router/server";
|
|
4
|
-
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
5
|
-
import { DocsBody, DocsDescription, DocsPage, DocsTitle, MarkdownCopyButton, ViewOptionsPopover } from "fumadocs-ui/layouts/docs/page";
|
|
6
|
-
//#region src/layouts/docs.tsx
|
|
7
|
-
function createDocsLayout({ render = async function defaultRender(page) {
|
|
8
|
-
let body;
|
|
9
|
-
let toc;
|
|
10
|
-
for (const adapter of this.adapters) {
|
|
11
|
-
body = await adapter["core:render-body"]?.call(this, page);
|
|
12
|
-
if (body !== void 0) break;
|
|
13
|
-
}
|
|
14
|
-
for (const adapter of this.adapters) {
|
|
15
|
-
toc = await adapter["core:render-toc"]?.call(this, page);
|
|
16
|
-
if (toc !== void 0) break;
|
|
17
|
-
}
|
|
18
|
-
if (body === void 0) throw new Error("[Fumapress] Please specify the `render` option in createDocsLayout()");
|
|
19
|
-
return {
|
|
20
|
-
body,
|
|
21
|
-
pageProps: { toc }
|
|
22
|
-
};
|
|
23
|
-
} } = {}) {
|
|
24
|
-
return async function Layout(props) {
|
|
25
|
-
const { slugs, lang, getLoader, data: { "core:docs-layout": layoutData } } = props;
|
|
26
|
-
const source = await getLoader();
|
|
27
|
-
const page = source.getPage(slugs, lang);
|
|
28
|
-
if (!page) unstable_notFound();
|
|
29
|
-
let result = await render.call(props, page);
|
|
30
|
-
result.layoutProps ??= {
|
|
31
|
-
tree: source.getPageTree(lang),
|
|
32
|
-
...baseOptions(props)
|
|
33
|
-
};
|
|
34
|
-
if (layoutData?.renderers) {
|
|
35
|
-
const renderCtx = { page };
|
|
36
|
-
for (const r of layoutData.renderers) result = await r.call(renderCtx, result);
|
|
37
|
-
}
|
|
38
|
-
return /* @__PURE__ */ jsxs(DocsLayout, {
|
|
39
|
-
...result.layoutProps,
|
|
40
|
-
children: [
|
|
41
|
-
renderPageMeta(page, props),
|
|
42
|
-
result.layoutProps.children,
|
|
43
|
-
/* @__PURE__ */ jsxs(DocsPage, {
|
|
44
|
-
...result.pageProps,
|
|
45
|
-
children: [
|
|
46
|
-
result.pageProps?.children,
|
|
47
|
-
/* @__PURE__ */ jsx(DocsTitle, { children: page.data.title }),
|
|
48
|
-
/* @__PURE__ */ jsx(DocsDescription, {
|
|
49
|
-
className: "mb-0",
|
|
50
|
-
children: page.data.description
|
|
51
|
-
}),
|
|
52
|
-
/* @__PURE__ */ jsxs("div", {
|
|
53
|
-
className: "flex flex-row gap-2 items-center border-b pt-2 pb-6",
|
|
54
|
-
children: [result.markdownUrl && /* @__PURE__ */ jsx(MarkdownCopyButton, { markdownUrl: result.markdownUrl }), /* @__PURE__ */ jsx(ViewOptionsPopover, {
|
|
55
|
-
markdownUrl: result.markdownUrl,
|
|
56
|
-
githubUrl: page.absolutePath ? getGitHubFileUrl(props, page.absolutePath) : void 0
|
|
57
|
-
})]
|
|
58
|
-
}),
|
|
59
|
-
/* @__PURE__ */ jsx(DocsBody, { children: result.body })
|
|
60
|
-
]
|
|
61
|
-
})
|
|
62
|
-
]
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
export { createDocsLayout };
|
package/dist/layouts/home.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ConfigContext } from "../config.js";
|
|
2
|
-
import { Layouts } from "../router.js";
|
|
3
|
-
import { AppContext } from "../lib/shared.js";
|
|
4
|
-
import { Awaitable } from "../lib/types.js";
|
|
5
|
-
import { ReactNode } from "react";
|
|
6
|
-
import { HomeLayoutProps } from "fumadocs-ui/layouts/home";
|
|
7
|
-
import { Page } from "fumadocs-core/source";
|
|
8
|
-
|
|
9
|
-
//#region src/layouts/home.d.ts
|
|
10
|
-
interface HomeLayoutOptions<C extends ConfigContext = ConfigContext> {
|
|
11
|
-
render?: (this: AppContext<C>, page: C['loaderConfig']['page']) => Awaitable<Partial<HomeLayoutRenderData>>;
|
|
12
|
-
}
|
|
13
|
-
interface HomeLayoutRenderData {
|
|
14
|
-
body: ReactNode;
|
|
15
|
-
layoutProps: HomeLayoutProps;
|
|
16
|
-
}
|
|
17
|
-
interface HomeLayoutContextData {
|
|
18
|
-
renderers?: ((this: {
|
|
19
|
-
page: Page;
|
|
20
|
-
}, data: HomeLayoutRenderData) => Awaitable<HomeLayoutRenderData>)[];
|
|
21
|
-
}
|
|
22
|
-
declare function createHomeLayout<C extends ConfigContext = ConfigContext>({
|
|
23
|
-
render
|
|
24
|
-
}: HomeLayoutOptions<C>): Layouts<C>['page'];
|
|
25
|
-
//#endregion
|
|
26
|
-
export { HomeLayoutContextData, HomeLayoutOptions, HomeLayoutRenderData, createHomeLayout };
|
package/dist/layouts/home.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { baseOptions, renderPageMeta } from "../lib/shared.js";
|
|
2
|
-
import { jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { unstable_notFound } from "waku/router/server";
|
|
4
|
-
import { HomeLayout } from "fumadocs-ui/layouts/home";
|
|
5
|
-
//#region src/layouts/home.tsx
|
|
6
|
-
function createHomeLayout({ render = async function renderDefault(page) {
|
|
7
|
-
for (const adapter of this.adapters) {
|
|
8
|
-
const body = await adapter["core:render-body"]?.call(this, page);
|
|
9
|
-
if (body !== void 0) return { body };
|
|
10
|
-
}
|
|
11
|
-
throw new Error("[Fumapress] Please specify the `render` option in createHomeLayout()");
|
|
12
|
-
} }) {
|
|
13
|
-
return async function Layout(props) {
|
|
14
|
-
const { slugs, lang, getLoader, data: { "core:home-layout": layoutData } } = props;
|
|
15
|
-
const page = (await getLoader()).getPage(slugs, lang);
|
|
16
|
-
if (!page) unstable_notFound();
|
|
17
|
-
let result = await render.call(props, page);
|
|
18
|
-
result.layoutProps ??= baseOptions(props);
|
|
19
|
-
if (layoutData?.renderers) {
|
|
20
|
-
const renderCtx = { page };
|
|
21
|
-
for (const r of layoutData.renderers) result = await r.call(renderCtx, result);
|
|
22
|
-
}
|
|
23
|
-
return /* @__PURE__ */ jsxs(HomeLayout, {
|
|
24
|
-
...result.layoutProps,
|
|
25
|
-
children: [
|
|
26
|
-
result.layoutProps.children,
|
|
27
|
-
renderPageMeta(page, props),
|
|
28
|
-
result.body
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
export { createHomeLayout };
|
package/dist/layouts/root.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ConfigContext } from "../config.js";
|
|
2
|
-
import { Layouts } from "../router.js";
|
|
3
|
-
|
|
4
|
-
//#region src/layouts/root.d.ts
|
|
5
|
-
declare function createRootLayout<C extends ConfigContext = ConfigContext>(): Layouts<C>['root'];
|
|
6
|
-
//#endregion
|
|
7
|
-
export { createRootLayout };
|
package/dist/layouts/root.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { renderRootMeta } from "../lib/shared.js";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import styles from "virtual:root.css?inline";
|
|
4
|
-
import { RootProvider } from "fumadocs-ui/provider/waku";
|
|
5
|
-
//#region src/layouts/root.tsx
|
|
6
|
-
function createRootLayout() {
|
|
7
|
-
return async function(props) {
|
|
8
|
-
const { children, lang, i18nConfig, data } = props;
|
|
9
|
-
const hooks = data["core:provider"];
|
|
10
|
-
let providerProps = {};
|
|
11
|
-
if (i18nConfig) providerProps.i18n = {
|
|
12
|
-
locale: lang,
|
|
13
|
-
locales: Object.entries(i18nConfig.languages).map(([k, v]) => ({
|
|
14
|
-
name: v.displayName,
|
|
15
|
-
locale: k
|
|
16
|
-
})),
|
|
17
|
-
translations: lang ? i18nConfig.languages[lang]?.translations : void 0
|
|
18
|
-
};
|
|
19
|
-
if (hooks) for (const hook of hooks) providerProps = await hook(providerProps);
|
|
20
|
-
return /* @__PURE__ */ jsxs("html", {
|
|
21
|
-
lang: lang ?? "en",
|
|
22
|
-
suppressHydrationWarning: true,
|
|
23
|
-
children: [/* @__PURE__ */ jsxs("head", { children: [/* @__PURE__ */ jsx("style", { children: styles }), renderRootMeta(props)] }), /* @__PURE__ */ jsx("body", {
|
|
24
|
-
"data-version": "1.0",
|
|
25
|
-
className: "flex flex-col min-h-screen",
|
|
26
|
-
children: /* @__PURE__ */ jsx(RootProvider, {
|
|
27
|
-
...providerProps,
|
|
28
|
-
children
|
|
29
|
-
})
|
|
30
|
-
})]
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { createRootLayout };
|
package/dist/lib/fs.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
//#region src/lib/fs.ts
|
|
4
|
-
/**
|
|
5
|
-
* Returns the absolute path to the root directory of the current git repository.
|
|
6
|
-
*/
|
|
7
|
-
function getGitRootDir(startDir = process.cwd()) {
|
|
8
|
-
let dir = startDir;
|
|
9
|
-
while (true) {
|
|
10
|
-
if (existsSync(join(dir, ".git"))) return dir;
|
|
11
|
-
const parent = dirname(dir);
|
|
12
|
-
if (parent === dir) break;
|
|
13
|
-
dir = parent;
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { getGitRootDir };
|
package/dist/lib/shared.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { BuildMode, Config, ConfigContext, I18nConfig } from "../config.js";
|
|
2
|
-
import { DocsLayoutContextData } from "../layouts/docs.js";
|
|
3
|
-
import { HomeLayoutContextData } from "../layouts/home.js";
|
|
4
|
-
import { Adapter, Awaitable, ServerPlugin } from "./types.js";
|
|
5
|
-
import { ReactNode } from "react";
|
|
6
|
-
import { RootProviderProps } from "fumadocs-ui/provider/waku";
|
|
7
|
-
import { LoaderOutput, Page } from "fumadocs-core/source";
|
|
8
|
-
//#region src/lib/shared.d.ts
|
|
9
|
-
interface AppContext<C extends ConfigContext = ConfigContext> {
|
|
10
|
-
mode: BuildMode;
|
|
11
|
-
getLoader: () => Awaitable<LoaderOutput<C['loaderConfig']>>;
|
|
12
|
-
plugins: ServerPlugin[];
|
|
13
|
-
adapters: Adapter[];
|
|
14
|
-
/** always `undefined`, easier way to infer types */
|
|
15
|
-
$context: C;
|
|
16
|
-
/**
|
|
17
|
-
* custom data in app context, can be referenced from plugins/pages etc
|
|
18
|
-
*/
|
|
19
|
-
data: AppContextData & Record<string, unknown>;
|
|
20
|
-
i18nConfig?: I18nConfig;
|
|
21
|
-
metaConfig?: Config['meta'];
|
|
22
|
-
siteConfig: {
|
|
23
|
-
name: string;
|
|
24
|
-
git?: {
|
|
25
|
-
user: string;
|
|
26
|
-
repo: string;
|
|
27
|
-
branch: string;
|
|
28
|
-
rootDir: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
interface AppContextData {
|
|
33
|
-
'core:page-meta'?: ((page: Page) => ReactNode)[];
|
|
34
|
-
'core:docs-layout'?: DocsLayoutContextData;
|
|
35
|
-
'core:home-layout'?: HomeLayoutContextData;
|
|
36
|
-
'core:provider'?: ((props: RootProviderProps) => Awaitable<RootProviderProps>)[];
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
export { AppContext, AppContextData };
|
package/dist/lib/shared.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { getGitRootDir } from "./fs.js";
|
|
2
|
-
import { fumadocsMdx } from "../adapters/mdx.js";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { Fragment } from "react";
|
|
5
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
//#region src/lib/shared.tsx
|
|
7
|
-
function parseConfig(config) {
|
|
8
|
-
const context = {
|
|
9
|
-
getLoader() {
|
|
10
|
-
if (typeof config.loader === "function") return config.loader();
|
|
11
|
-
return config.loader;
|
|
12
|
-
},
|
|
13
|
-
plugins: Array.isArray(config.plugins) ? config.plugins : [],
|
|
14
|
-
adapters: config.adapters ?? [fumadocsMdx()],
|
|
15
|
-
$context: void 0,
|
|
16
|
-
data: {},
|
|
17
|
-
i18nConfig: config.i18n,
|
|
18
|
-
mode: config.mode ?? "default",
|
|
19
|
-
metaConfig: config.meta,
|
|
20
|
-
siteConfig: {
|
|
21
|
-
name: config.site?.name ?? "Fumapress",
|
|
22
|
-
git: config.site?.git ? {
|
|
23
|
-
...config.site.git,
|
|
24
|
-
rootDir: config.site.git.rootDir ?? getGitRootDir() ?? process.cwd()
|
|
25
|
-
} : void 0
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
if (typeof config.plugins === "function") context.plugins = config.plugins(context);
|
|
29
|
-
return context;
|
|
30
|
-
}
|
|
31
|
-
function renderRootMeta(context) {
|
|
32
|
-
return context.metaConfig?.root?.call(context);
|
|
33
|
-
}
|
|
34
|
-
function renderPageMeta(page, context) {
|
|
35
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
36
|
-
/* @__PURE__ */ jsx("title", { children: page.data.title }),
|
|
37
|
-
/* @__PURE__ */ jsx("meta", {
|
|
38
|
-
property: "og:title",
|
|
39
|
-
content: page.data.title
|
|
40
|
-
}),
|
|
41
|
-
page.data.description && /* @__PURE__ */ jsx("meta", {
|
|
42
|
-
property: "og:description",
|
|
43
|
-
content: page.data.description
|
|
44
|
-
}),
|
|
45
|
-
context.metaConfig?.page?.call(context, page),
|
|
46
|
-
context.data["core:page-meta"]?.map((hook, i) => /* @__PURE__ */ jsx(Fragment, { children: hook(page) }, i))
|
|
47
|
-
] });
|
|
48
|
-
}
|
|
49
|
-
function getGitHubFileUrl(ctx, absolutePath) {
|
|
50
|
-
const { git } = ctx.siteConfig;
|
|
51
|
-
if (!git) return;
|
|
52
|
-
const p = path.relative(git.rootDir, absolutePath).replaceAll(path.sep, "/");
|
|
53
|
-
if (p.startsWith("../")) return;
|
|
54
|
-
return `https://github.com/${git.user}/${git.repo}/blob/${git.branch}/${p}`;
|
|
55
|
-
}
|
|
56
|
-
function baseOptions(ctx) {
|
|
57
|
-
const { name, git } = ctx.siteConfig;
|
|
58
|
-
return {
|
|
59
|
-
nav: { title: name },
|
|
60
|
-
githubUrl: git ? `https://github.com/${git.user}/${git.repo}` : void 0
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
export { baseOptions, getGitHubFileUrl, parseConfig, renderPageMeta, renderRootMeta };
|
package/dist/lib/types.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "./shared.js";
|
|
2
|
-
import { createPages } from "waku";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
|
-
import { Page } from "fumadocs-core/source";
|
|
5
|
-
import { StructuredData } from "fumadocs-core/mdx-plugins";
|
|
6
|
-
import { TOCItemType } from "fumadocs-core/toc";
|
|
7
|
-
|
|
8
|
-
//#region src/lib/types.d.ts
|
|
9
|
-
type Awaitable<T> = T | Promise<T>;
|
|
10
|
-
/** allow content sources to implement interfaces for pages, instead of requiring consumers to specify manually */
|
|
11
|
-
interface Adapter {
|
|
12
|
-
'core:get-text'?: (this: AppContext, page: Page) => Awaitable<string | undefined>;
|
|
13
|
-
'core:get-structured-data'?: (this: AppContext, page: Page) => Awaitable<StructuredData | undefined>;
|
|
14
|
-
'core:render-body'?: (this: AppContext, page: Page) => Awaitable<ReactNode>;
|
|
15
|
-
'core:render-toc'?: (this: AppContext, page: Page) => Awaitable<TOCItemType[] | undefined>;
|
|
16
|
-
}
|
|
17
|
-
interface ServerPlugin {
|
|
18
|
-
/** receive & modify context */
|
|
19
|
-
init?: (this: AppContext) => void;
|
|
20
|
-
createPages?: (this: AppContext, fns: RouteFns) => Awaitable<void>;
|
|
21
|
-
}
|
|
22
|
-
type RouteFns = Parameters<Parameters<typeof createPages>[0]>[0] & {
|
|
23
|
-
createApiIsomorphic: (config: {
|
|
24
|
-
render: 'static' | 'dynamic';
|
|
25
|
-
path: string;
|
|
26
|
-
staticPaths?: string[][];
|
|
27
|
-
handler: (req: Request, ctx: {
|
|
28
|
-
params: Record<string, string | string[]>;
|
|
29
|
-
}) => Promise<Response>;
|
|
30
|
-
}) => void;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
|
-
export { Adapter, Awaitable, ServerPlugin };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ConfigContext } from "../config.js";
|
|
2
|
-
import { AppContext } from "../lib/shared.js";
|
|
3
|
-
import { Awaitable, ServerPlugin } from "../lib/types.js";
|
|
4
|
-
import { Index } from "fumadocs-core/search/flexsearch";
|
|
5
|
-
|
|
6
|
-
//#region src/plugins/flexsearch.d.ts
|
|
7
|
-
interface FlexsearchOptions<C extends ConfigContext = ConfigContext> {
|
|
8
|
-
buildIndex?: (this: AppContext<C>, page: C['loaderConfig']['page']) => Awaitable<Index>;
|
|
9
|
-
}
|
|
10
|
-
declare function flexsearchPlugin<C extends ConfigContext = ConfigContext>({
|
|
11
|
-
buildIndex
|
|
12
|
-
}?: FlexsearchOptions<C>): ServerPlugin;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { FlexsearchOptions, flexsearchPlugin };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import DefaultSearchDialog from "../components/flexsearch-static.js";
|
|
2
|
-
//#region src/plugins/flexsearch.ts
|
|
3
|
-
function flexsearchPlugin({ buildIndex = async function buildIndexDefault(page) {
|
|
4
|
-
for (const adapter of this.adapters) {
|
|
5
|
-
const structuredData = await adapter["core:get-structured-data"]?.call(this, page);
|
|
6
|
-
if (structuredData !== void 0) return {
|
|
7
|
-
id: page.url,
|
|
8
|
-
title: page.data.title ?? page.path,
|
|
9
|
-
description: page.data.description,
|
|
10
|
-
url: page.url,
|
|
11
|
-
structuredData
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
throw new Error("[Fumapress] Please specify the `buildIndex` option to flexsearchPlugin()");
|
|
15
|
-
} } = {}) {
|
|
16
|
-
return {
|
|
17
|
-
init() {
|
|
18
|
-
if (this.mode === "static") (this.data["core:provider"] ??= []).push((props) => {
|
|
19
|
-
props.search ??= {};
|
|
20
|
-
props.search.SearchDialog ??= DefaultSearchDialog;
|
|
21
|
-
return props;
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
async createPages({ createApiIsomorphic }) {
|
|
25
|
-
const { flexsearchFromSource } = await import("fumadocs-core/search/flexsearch");
|
|
26
|
-
const server = flexsearchFromSource(this.getLoader, { buildIndex: buildIndex.bind(this) });
|
|
27
|
-
createApiIsomorphic({
|
|
28
|
-
render: this.mode === "static" ? "static" : "dynamic",
|
|
29
|
-
path: "/api/search",
|
|
30
|
-
handler: this.mode === "static" ? server.staticGET : server.GET
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { flexsearchPlugin };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ConfigContext } from "../config.js";
|
|
2
|
-
import { AppContext } from "../lib/shared.js";
|
|
3
|
-
import { Awaitable, ServerPlugin } from "../lib/types.js";
|
|
4
|
-
|
|
5
|
-
//#region src/plugins/llms.txt.d.ts
|
|
6
|
-
interface LLMsOptions<C extends ConfigContext = ConfigContext> {
|
|
7
|
-
getLLMText?: (this: AppContext<C>, page: C['loaderConfig']['page']) => Awaitable<string>;
|
|
8
|
-
}
|
|
9
|
-
declare function llmsPlugin<C extends ConfigContext = ConfigContext>(options?: LLMsOptions<C>): ServerPlugin;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { LLMsOptions, llmsPlugin };
|
package/dist/plugins/llms.txt.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { unstable_notFound } from "waku/router/server";
|
|
2
|
-
import { llms } from "fumadocs-core/source/llms";
|
|
3
|
-
//#region src/plugins/llms.txt.ts
|
|
4
|
-
function llmsPlugin(options = {}) {
|
|
5
|
-
const { getLLMText: _getLLMText = async function getLLMTextDefault(page) {
|
|
6
|
-
for (const adapter of this.adapters) {
|
|
7
|
-
const txt = await adapter["core:get-text"]?.call(this, page);
|
|
8
|
-
if (txt !== void 0) return `# ${page.data.title} (${page.url})\n\n${txt}`;
|
|
9
|
-
}
|
|
10
|
-
throw new Error("[Fumapress] Please specify the `getLLMText()` option in llmsPlugin()");
|
|
11
|
-
} } = options;
|
|
12
|
-
return {
|
|
13
|
-
init() {
|
|
14
|
-
this.data["core:docs-layout"] ??= {};
|
|
15
|
-
this.data["core:docs-layout"].renderers ??= [];
|
|
16
|
-
this.data["core:docs-layout"].renderers.push(function(res) {
|
|
17
|
-
res.markdownUrl ??= slugsToMarkdownPath(this.page.slugs, this.page.locale).url;
|
|
18
|
-
return res;
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
async createPages({ createApiIsomorphic }) {
|
|
22
|
-
const defaultRenderMode = this.mode === "dynamic" ? "dynamic" : "static";
|
|
23
|
-
const getLLMText = _getLLMText.bind(this);
|
|
24
|
-
createApiIsomorphic({
|
|
25
|
-
render: defaultRenderMode,
|
|
26
|
-
path: "/llms.txt",
|
|
27
|
-
handler: async () => {
|
|
28
|
-
const source = await this.getLoader();
|
|
29
|
-
return new Response(llms(source).index());
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
createApiIsomorphic({
|
|
33
|
-
render: defaultRenderMode,
|
|
34
|
-
path: "/llms-full.txt",
|
|
35
|
-
handler: async () => {
|
|
36
|
-
const scan = (await this.getLoader()).getPages().map(getLLMText);
|
|
37
|
-
const scanned = await Promise.all(scan);
|
|
38
|
-
return new Response(scanned.join("\n\n"));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
createApiIsomorphic({
|
|
42
|
-
render: defaultRenderMode,
|
|
43
|
-
path: this.i18nConfig ? "/[lang]/[...slugs]" : "/[...slugs]",
|
|
44
|
-
staticPaths: defaultRenderMode === "static" ? (await this.getLoader()).getPages().map((page) => slugsToMarkdownPath(page.slugs, page.locale).segments) : void 0,
|
|
45
|
-
handler: async (_req, { params }) => {
|
|
46
|
-
const page = (await this.getLoader()).getPage(markdownPathToSlugs(params.slugs), params.lang);
|
|
47
|
-
if (!page) unstable_notFound();
|
|
48
|
-
return new Response(await getLLMText(page), { headers: { "Content-Type": "text/markdown" } });
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function markdownPathToSlugs(segs) {
|
|
55
|
-
const slugs = [...segs];
|
|
56
|
-
if (slugs.length === 0) return slugs;
|
|
57
|
-
slugs[slugs.length - 1] = slugs[slugs.length - 1].replace(/\.md$/, "");
|
|
58
|
-
if (slugs.length === 1 && slugs[0] === "index") slugs.pop();
|
|
59
|
-
return slugs;
|
|
60
|
-
}
|
|
61
|
-
function slugsToMarkdownPath(slugs, lang) {
|
|
62
|
-
const segments = [...slugs];
|
|
63
|
-
if (segments.length === 0) segments.push("index.md");
|
|
64
|
-
else segments[segments.length - 1] += ".md";
|
|
65
|
-
if (lang) segments.unshift(lang);
|
|
66
|
-
return {
|
|
67
|
-
segments,
|
|
68
|
-
url: `/${segments.join("/")}`
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
export { llmsPlugin };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ConfigContext } from "../config.js";
|
|
2
|
-
import { AppContext } from "../lib/shared.js";
|
|
3
|
-
import { Awaitable, ServerPlugin } from "../lib/types.js";
|
|
4
|
-
import { AdvancedIndex } from "fumadocs-core/search/server";
|
|
5
|
-
|
|
6
|
-
//#region src/plugins/orama-search.d.ts
|
|
7
|
-
interface OramaSearchOptions<C extends ConfigContext = ConfigContext> {
|
|
8
|
-
buildIndex?: (this: AppContext<C>, page: C['loaderConfig']['page']) => Awaitable<AdvancedIndex>;
|
|
9
|
-
}
|
|
10
|
-
declare function oramaSearchPlugin<C extends ConfigContext = ConfigContext>({
|
|
11
|
-
buildIndex
|
|
12
|
-
}?: OramaSearchOptions<C>): ServerPlugin;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { OramaSearchOptions, oramaSearchPlugin };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region src/plugins/orama-search.ts
|
|
2
|
-
function oramaSearchPlugin({ buildIndex = async function buildIndexDefault(page) {
|
|
3
|
-
for (const adapter of this.adapters) {
|
|
4
|
-
const structuredData = await adapter["core:get-structured-data"]?.call(this, page);
|
|
5
|
-
if (structuredData !== void 0) return {
|
|
6
|
-
id: page.url,
|
|
7
|
-
title: page.data.title ?? page.path,
|
|
8
|
-
description: page.data.description,
|
|
9
|
-
url: page.url,
|
|
10
|
-
structuredData
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
throw new Error("[Fumapress] Please specify the `buildIndex` option to oramaSearchPlugin()");
|
|
14
|
-
} } = {}) {
|
|
15
|
-
return {
|
|
16
|
-
init() {
|
|
17
|
-
if (this.mode === "static") (this.data["core:provider"] ??= []).push(async (props) => {
|
|
18
|
-
props.search ??= {};
|
|
19
|
-
props.search.SearchDialog ??= (await import("../components/orama-search-static.js")).default;
|
|
20
|
-
return props;
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
async createPages({ createApiIsomorphic }) {
|
|
24
|
-
const { createFromSource } = await import("fumadocs-core/search/server");
|
|
25
|
-
const server = createFromSource(this.getLoader, { buildIndex: buildIndex.bind(this) });
|
|
26
|
-
createApiIsomorphic({
|
|
27
|
-
render: this.mode === "static" ? "static" : "dynamic",
|
|
28
|
-
path: "/api/search",
|
|
29
|
-
handler: this.mode === "static" ? server.staticGET : server.GET
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { oramaSearchPlugin };
|
package/dist/plugins/takumi.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ConfigContext } from "../config.js";
|
|
2
|
-
import { AppContext } from "../lib/shared.js";
|
|
3
|
-
import { Awaitable, ServerPlugin } from "../lib/types.js";
|
|
4
|
-
import { ReactNode } from "react";
|
|
5
|
-
import { ImageResponseOptions } from "@takumi-rs/image-response";
|
|
6
|
-
|
|
7
|
-
//#region src/plugins/takumi.d.ts
|
|
8
|
-
interface TakumiOptions<C extends ConfigContext = ConfigContext> {
|
|
9
|
-
generate?: (this: AppContext<C>, page: C['loaderConfig']['page']) => Awaitable<{
|
|
10
|
-
node: ReactNode;
|
|
11
|
-
options?: Partial<ImageResponseOptions>;
|
|
12
|
-
}>;
|
|
13
|
-
}
|
|
14
|
-
declare function takumiPlugin<C extends ConfigContext = ConfigContext>(options?: TakumiOptions<C>): ServerPlugin;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { TakumiOptions, takumiPlugin };
|
package/dist/plugins/takumi.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { unstable_notFound } from "waku/router/server";
|
|
3
|
-
import { ImageResponse } from "@takumi-rs/image-response";
|
|
4
|
-
//#region src/plugins/takumi.tsx
|
|
5
|
-
function takumiPlugin(options = {}) {
|
|
6
|
-
const { generate = async function generateDefault(page) {
|
|
7
|
-
const { generate } = await import("fumadocs-ui/og/takumi");
|
|
8
|
-
return { node: generate({
|
|
9
|
-
title: page.data.title,
|
|
10
|
-
description: page.data.description,
|
|
11
|
-
site: this.siteConfig.name
|
|
12
|
-
}) };
|
|
13
|
-
} } = options;
|
|
14
|
-
const width = 1200;
|
|
15
|
-
const height = 630;
|
|
16
|
-
return {
|
|
17
|
-
init() {
|
|
18
|
-
(this.data["core:page-meta"] ??= []).push((page) => {
|
|
19
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20
|
-
/* @__PURE__ */ jsx("meta", {
|
|
21
|
-
property: "og:image",
|
|
22
|
-
content: slugsToImagePath(page.slugs, page.locale).url
|
|
23
|
-
}),
|
|
24
|
-
/* @__PURE__ */ jsx("meta", {
|
|
25
|
-
property: "og:image:width",
|
|
26
|
-
content: `${width}`
|
|
27
|
-
}),
|
|
28
|
-
/* @__PURE__ */ jsx("meta", {
|
|
29
|
-
property: "og:image:height",
|
|
30
|
-
content: `${height}`
|
|
31
|
-
}),
|
|
32
|
-
/* @__PURE__ */ jsx("meta", {
|
|
33
|
-
property: "twitter:card",
|
|
34
|
-
content: "summary_large_image"
|
|
35
|
-
})
|
|
36
|
-
] });
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
async createPages({ createApiIsomorphic }) {
|
|
40
|
-
const renderMode = this.mode === "dynamic" ? "dynamic" : "static";
|
|
41
|
-
createApiIsomorphic({
|
|
42
|
-
render: renderMode,
|
|
43
|
-
path: this.i18nConfig ? "/[lang]/[...slugs]" : "/[...slugs]",
|
|
44
|
-
staticPaths: renderMode === "static" ? (await this.getLoader()).getPages().map((page) => slugsToImagePath(page.slugs, page.locale).segments) : void 0,
|
|
45
|
-
handler: async (_, { params }) => {
|
|
46
|
-
const page = (await this.getLoader()).getPage(imagePathToSlugs(params.slugs), params.lang);
|
|
47
|
-
if (!page) unstable_notFound();
|
|
48
|
-
const { node, options } = await generate.call(this, page);
|
|
49
|
-
return new ImageResponse(node, {
|
|
50
|
-
width,
|
|
51
|
-
height,
|
|
52
|
-
...options,
|
|
53
|
-
format: "webp"
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function slugsToImagePath(slugs, lang) {
|
|
61
|
-
const segments = [...slugs];
|
|
62
|
-
if (segments.length === 0) segments.push("index.webp");
|
|
63
|
-
else segments[segments.length - 1] += ".webp";
|
|
64
|
-
if (lang) segments.unshift(lang);
|
|
65
|
-
return {
|
|
66
|
-
segments,
|
|
67
|
-
url: `/${segments.join("/")}`
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function imagePathToSlugs(segs) {
|
|
71
|
-
const slugs = [...segs];
|
|
72
|
-
if (slugs.length === 0) return slugs;
|
|
73
|
-
slugs[slugs.length - 1] = slugs[slugs.length - 1].replace(/\.webp$/, "");
|
|
74
|
-
if (slugs.length === 1 && slugs[0] === "index") slugs.pop();
|
|
75
|
-
return slugs;
|
|
76
|
-
}
|
|
77
|
-
//#endregion
|
|
78
|
-
export { takumiPlugin };
|
package/dist/router.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Config, ConfigContext } from "./config.js";
|
|
2
|
-
import { AppContext } from "./lib/shared.js";
|
|
3
|
-
import * as waku from "waku";
|
|
4
|
-
import { ComponentType, ReactNode } from "react";
|
|
5
|
-
|
|
6
|
-
//#region src/router.d.ts
|
|
7
|
-
type RouterOptions<C extends ConfigContext = ConfigContext> = Partial<Layouts<C>>;
|
|
8
|
-
interface Layouts<C extends ConfigContext = ConfigContext> {
|
|
9
|
-
root: ComponentType<AppContext<C> & {
|
|
10
|
-
lang?: string;
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
}>;
|
|
13
|
-
page: ComponentType<AppContext<C> & {
|
|
14
|
-
lang?: string;
|
|
15
|
-
slugs: string[];
|
|
16
|
-
}>;
|
|
17
|
-
notFound: ComponentType<AppContext<C> & {
|
|
18
|
-
lang?: string;
|
|
19
|
-
}>;
|
|
20
|
-
}
|
|
21
|
-
declare function createRouter<C extends ConfigContext>(rawConfig: Config<C>, options?: RouterOptions<NoInfer<C>>): {
|
|
22
|
-
extend: typeof waku.createPages;
|
|
23
|
-
createPages: () => ReturnType<typeof waku.createPages>;
|
|
24
|
-
};
|
|
25
|
-
//#endregion
|
|
26
|
-
export { Layouts, RouterOptions, createRouter };
|
package/dist/router.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
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(rawConfig, options = {}) {
|
|
7
|
-
async function init() {
|
|
8
|
-
const context = parseConfig(rawConfig);
|
|
9
|
-
for (const plugin of context.plugins) plugin.init?.call(context);
|
|
10
|
-
return {
|
|
11
|
-
context,
|
|
12
|
-
root: options.root ?? (await import("./layouts/root.js")).createRootLayout(),
|
|
13
|
-
page: options.page ?? (await import("./layouts/docs.js")).createDocsLayout(),
|
|
14
|
-
notFound: options.notFound ?? (await import("fumadocs-ui/layouts/home/not-found")).DefaultNotFound
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const createPages = (base, createPagesOptions) => {
|
|
18
|
-
return waku.createPages(async (_fns) => {
|
|
19
|
-
const { context, ...layouts } = await init();
|
|
20
|
-
const fns = {
|
|
21
|
-
..._fns,
|
|
22
|
-
createApiIsomorphic(config) {
|
|
23
|
-
if (config.render === "static") _fns.createApi({
|
|
24
|
-
render: "static",
|
|
25
|
-
method: "GET",
|
|
26
|
-
staticPaths: config.staticPaths,
|
|
27
|
-
path: config.path,
|
|
28
|
-
handler: config.handler
|
|
29
|
-
});
|
|
30
|
-
else _fns.createApi({
|
|
31
|
-
render: "dynamic",
|
|
32
|
-
path: config.path,
|
|
33
|
-
handlers: { GET: config.handler }
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
await base(fns);
|
|
38
|
-
for (const plugin of context.plugins) await plugin.createPages?.call(context, fns);
|
|
39
|
-
const defaultRenderMode = context.mode === "dynamic" ? "dynamic" : "static";
|
|
40
|
-
if (context.i18nConfig) {
|
|
41
|
-
fns.createRoot({
|
|
42
|
-
render: defaultRenderMode,
|
|
43
|
-
component({ children }) {
|
|
44
|
-
return children;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
fns.createLayout({
|
|
48
|
-
render: defaultRenderMode,
|
|
49
|
-
path: "/[lang]",
|
|
50
|
-
component({ children, lang }) {
|
|
51
|
-
return createElement(layouts.root, {
|
|
52
|
-
lang,
|
|
53
|
-
children,
|
|
54
|
-
...context
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
fns.createPage({
|
|
59
|
-
render: defaultRenderMode,
|
|
60
|
-
path: "/[lang]/[...slugs]",
|
|
61
|
-
staticPaths: (await context.getLoader()).getPages().map((page) => [page.locale, ...page.slugs]),
|
|
62
|
-
component({ slugs, lang }) {
|
|
63
|
-
return createElement(layouts.page, {
|
|
64
|
-
lang,
|
|
65
|
-
slugs,
|
|
66
|
-
...context
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
fns.createPage({
|
|
71
|
-
render: defaultRenderMode,
|
|
72
|
-
path: "/[lang]/404",
|
|
73
|
-
staticPaths: Object.keys(context.i18nConfig.languages),
|
|
74
|
-
component({ lang }) {
|
|
75
|
-
return createElement(layouts.notFound, {
|
|
76
|
-
lang,
|
|
77
|
-
...context
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
if (context.mode !== "static") fns.createPage({
|
|
82
|
-
render: "dynamic",
|
|
83
|
-
path: "/404",
|
|
84
|
-
component() {
|
|
85
|
-
unstable_redirect(`/${context.i18nConfig.defaultLanguage}`);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
} else {
|
|
89
|
-
fns.createRoot({
|
|
90
|
-
render: defaultRenderMode,
|
|
91
|
-
component({ children }) {
|
|
92
|
-
return createElement(layouts.root, {
|
|
93
|
-
children,
|
|
94
|
-
...context
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
fns.createPage({
|
|
99
|
-
render: defaultRenderMode,
|
|
100
|
-
path: "/[...slugs]",
|
|
101
|
-
staticPaths: (await context.getLoader()).getPages().map((page) => page.slugs),
|
|
102
|
-
component({ slugs }) {
|
|
103
|
-
return createElement(layouts.page, {
|
|
104
|
-
slugs,
|
|
105
|
-
...context
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
fns.createPage({
|
|
110
|
-
render: defaultRenderMode,
|
|
111
|
-
staticPaths: [],
|
|
112
|
-
path: "/404",
|
|
113
|
-
component() {
|
|
114
|
-
return createElement(layouts.notFound, context);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
}, createPagesOptions);
|
|
120
|
-
};
|
|
121
|
-
return {
|
|
122
|
-
extend: createPages,
|
|
123
|
-
createPages() {
|
|
124
|
-
return createPages(() => null);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
129
|
-
export { createRouter };
|
package/dist/vite.d.ts
DELETED
package/dist/vite.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { crawlFrameworkPkgs } from "vitefu";
|
|
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 === "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 };
|