fumapress 0.2.5 → 0.3.1
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 +155 -8
- package/dist/_virtual/_rolldown/runtime.js +24 -0
- package/dist/adapters/mdx/schema.d.ts +39 -0
- package/dist/adapters/mdx/schema.js +9 -0
- package/dist/adapters/mdx.js +25 -5
- package/dist/adapters/openapi.d.ts +15 -0
- package/dist/adapters/openapi.js +22 -0
- package/dist/components/blog-panel.js +56 -0
- package/dist/components/blog.js +60 -0
- package/dist/config.d.ts +23 -10
- package/dist/index.d.ts +2 -2
- package/dist/layouts/blog.d.ts +21 -0
- package/dist/layouts/blog.index.d.ts +15 -0
- package/dist/layouts/blog.index.js +36 -0
- package/dist/layouts/blog.js +82 -0
- package/dist/layouts/blog.tags.d.ts +19 -0
- package/dist/layouts/blog.tags.js +113 -0
- package/dist/layouts/docs.d.ts +3 -3
- package/dist/layouts/docs.js +24 -51
- package/dist/layouts/home.d.ts +18 -6
- package/dist/layouts/home.js +37 -21
- package/dist/layouts/notebook.d.ts +3 -3
- package/dist/layouts/notebook.js +24 -51
- package/dist/layouts/root.js +5 -6
- package/dist/layouts/switch.d.ts +11 -0
- package/dist/layouts/switch.js +21 -0
- package/dist/lib/cn.js +2 -0
- package/dist/lib/join-pathname.js +9 -0
- package/dist/lib/shared/blog.js +39 -0
- package/dist/lib/shared.d.ts +3 -2
- package/dist/lib/shared.js +50 -11
- package/dist/lib/types.d.ts +20 -6
- package/dist/node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js +108 -0
- package/dist/plugins/blog.d.ts +72 -0
- package/dist/plugins/blog.js +175 -0
- package/dist/plugins/llms.txt.d.ts +1 -1
- package/dist/plugins/llms.txt.js +5 -5
- package/dist/plugins/openapi.d.ts +13 -0
- package/dist/plugins/openapi.js +21 -0
- package/dist/router.d.ts +7 -6
- package/dist/router.js +49 -40
- package/dist/vite.d.ts +11 -3
- package/dist/vite.js +3 -4
- package/package.json +32 -11
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { joinPathname } from "../lib/join-pathname.js";
|
|
3
|
+
import { OrderedBlogGrid } from "../components/blog.js";
|
|
4
|
+
import { Link } from "waku";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
7
|
+
import { ListIcon } from "lucide-react";
|
|
8
|
+
//#region src/layouts/blog.index.tsx
|
|
9
|
+
function createBlogIndexPage({ heading, description } = {}) {
|
|
10
|
+
return async function BlogIndexPage({ lang, blog, ctx }) {
|
|
11
|
+
const source = await ctx.getLoader();
|
|
12
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
13
|
+
className: "flex flex-col gap-4 items-start border-2 border-dashed border-fd-primary rounded-xl bg-fd-primary/10 p-4 z-2 md:p-8",
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsx("h1", {
|
|
16
|
+
className: "text-3xl font-semibold",
|
|
17
|
+
children: heading ?? "Blog"
|
|
18
|
+
}),
|
|
19
|
+
/* @__PURE__ */ jsx("p", {
|
|
20
|
+
className: "text-fd-primary overline decoration-fd-primary empty:hidden",
|
|
21
|
+
children: description
|
|
22
|
+
}),
|
|
23
|
+
blog.tagsPath !== false && /* @__PURE__ */ jsxs(Link, {
|
|
24
|
+
to: lang ? joinPathname(lang, blog.tagsPath) : blog.tagsPath,
|
|
25
|
+
className: cn(buttonVariants({ variant: "primary" }), "gap-2"),
|
|
26
|
+
children: [/* @__PURE__ */ jsx(ListIcon, { className: "size-4" }), "All Tags"]
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
}), /* @__PURE__ */ jsx(OrderedBlogGrid, {
|
|
30
|
+
posts: source.getPages(lang).filter((page) => blog.isBlog.call(ctx, page)),
|
|
31
|
+
ctx
|
|
32
|
+
})] });
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { createBlogIndexPage };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { getCreationDate, renderBody, renderPageMeta, renderToc } from "../lib/shared.js";
|
|
2
|
+
import { joinPathname } from "../lib/join-pathname.js";
|
|
3
|
+
import { LinkToHome } from "../components/blog.js";
|
|
4
|
+
import { getTags } from "../lib/shared/blog.js";
|
|
5
|
+
import { BlogPanel, BlogProvider } from "../components/blog-panel.js";
|
|
6
|
+
import { createHomeLayout } from "./home.js";
|
|
7
|
+
import { Link } from "waku";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { TagIcon } from "lucide-react";
|
|
10
|
+
//#region src/layouts/blog.tsx
|
|
11
|
+
function createBlogLayout(options) {
|
|
12
|
+
const HomeLayout = createHomeLayout(options);
|
|
13
|
+
return function BlogLayout({ children, ctx, lang }) {
|
|
14
|
+
return /* @__PURE__ */ jsx(HomeLayout, {
|
|
15
|
+
lang,
|
|
16
|
+
ctx,
|
|
17
|
+
children: /* @__PURE__ */ jsx("main", {
|
|
18
|
+
className: "flex flex-col w-full max-w-[1400px] flex-1 px-4 pt-6 pb-20 mx-auto",
|
|
19
|
+
children
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function createBlogLayoutPage(options = {}) {
|
|
25
|
+
const { render } = options;
|
|
26
|
+
return async function BlogLayoutPage({ ctx, page, blog, lang }) {
|
|
27
|
+
const tags = await getTags(ctx, page);
|
|
28
|
+
const _raw = await render?.call(ctx, page);
|
|
29
|
+
const result = {
|
|
30
|
+
body: _raw?.body ?? await renderBody(ctx, page, "[Fumapress] Please specify the `render` option in createBlogLayoutPage()"),
|
|
31
|
+
toc: _raw?.toc ?? await renderToc(ctx, page) ?? [],
|
|
32
|
+
creationDate: _raw?.creationDate ?? await getCreationDate(ctx, page)
|
|
33
|
+
};
|
|
34
|
+
return /* @__PURE__ */ jsxs(BlogProvider, {
|
|
35
|
+
toc: result.toc,
|
|
36
|
+
children: [
|
|
37
|
+
renderPageMeta(page, ctx),
|
|
38
|
+
/* @__PURE__ */ jsxs("div", {
|
|
39
|
+
className: "flex flex-col gap-4 items-center border-y px-4 pt-3.5 pb-6 bg-fd-card text-fd-card-foreground shadow-inner max-sm:-mx-4 sm:rounded-xl sm:border",
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx("div", {
|
|
42
|
+
className: "flex flex-row items-center gap-2 w-full max-w-[900px]",
|
|
43
|
+
children: /* @__PURE__ */ jsx(LinkToHome, {
|
|
44
|
+
blog,
|
|
45
|
+
lang
|
|
46
|
+
})
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsx("h1", {
|
|
49
|
+
className: "font-semibold text-2xl w-full max-w-[900px]",
|
|
50
|
+
children: page.data.title
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsx("p", {
|
|
53
|
+
className: "text-fd-muted-foreground w-full max-w-[900px]",
|
|
54
|
+
children: page.data.description
|
|
55
|
+
}),
|
|
56
|
+
tags && tags.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
57
|
+
className: "flex flex-row items-center gap-2 flex-wrap w-full max-w-[900px] text-sm text-fd-primary-foreground font-mono",
|
|
58
|
+
children: [/* @__PURE__ */ jsx(TagIcon, { className: "size-4 text-fd-muted-foreground" }), tags.map((t) => {
|
|
59
|
+
if (blog.tagsPath !== false) return /* @__PURE__ */ jsx(Link, {
|
|
60
|
+
to: joinPathname(lang ?? "", blog.tagsPath, t),
|
|
61
|
+
className: "px-1.5 py-0.5 rounded-lg bg-fd-primary",
|
|
62
|
+
children: t
|
|
63
|
+
}, t);
|
|
64
|
+
return /* @__PURE__ */ jsx("p", {
|
|
65
|
+
className: "px-1.5 py-0.5 rounded-lg bg-fd-primary",
|
|
66
|
+
children: t
|
|
67
|
+
}, t);
|
|
68
|
+
})]
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx("article", {
|
|
73
|
+
className: "prose mt-6 mx-auto w-full max-w-[900px]",
|
|
74
|
+
children: result.body
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx(BlogPanel, {})
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { createBlogLayout, createBlogLayoutPage };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ConfigContext } from "../config.js";
|
|
2
|
+
import { BlogTagPage, BlogTagsPage } from "../plugins/blog.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/layouts/blog.tags.d.ts
|
|
6
|
+
interface BlogTagsPageOptions {
|
|
7
|
+
heading?: ReactNode;
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
declare function createBlogTagsPage<C extends ConfigContext = ConfigContext>({
|
|
11
|
+
heading,
|
|
12
|
+
description
|
|
13
|
+
}?: BlogTagsPageOptions): BlogTagsPage<C>;
|
|
14
|
+
declare function createBlogTagPage<C extends ConfigContext = ConfigContext>({
|
|
15
|
+
heading,
|
|
16
|
+
description
|
|
17
|
+
}?: BlogTagsPageOptions): BlogTagPage<C>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { BlogTagsPageOptions, createBlogTagPage, createBlogTagsPage };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { LinkToHome, OrderedBlogGrid } from "../components/blog.js";
|
|
2
|
+
import { getTags, groupTags } from "../lib/shared/blog.js";
|
|
3
|
+
import { Link } from "waku";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { NewspaperIcon, TagIcon } from "lucide-react";
|
|
6
|
+
//#region src/layouts/blog.tags.tsx
|
|
7
|
+
function createBlogTagsPage({ heading, description } = {}) {
|
|
8
|
+
return async function BlogTagsPage({ lang, blog, ctx }) {
|
|
9
|
+
const grouped = await groupTags(ctx, (await ctx.getLoader()).getPages(lang).filter((page) => blog.isBlog.call(ctx, page)));
|
|
10
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
11
|
+
className: "flex flex-col items-start gap-4 border-y px-4 pt-3.5 pb-6 bg-fd-card text-fd-card-foreground shadow-inner max-sm:-mx-4 sm:rounded-xl sm:border",
|
|
12
|
+
children: [
|
|
13
|
+
/* @__PURE__ */ jsx(LinkToHome, {
|
|
14
|
+
lang,
|
|
15
|
+
blog
|
|
16
|
+
}),
|
|
17
|
+
/* @__PURE__ */ jsx("h1", {
|
|
18
|
+
className: "font-semibold text-2xl",
|
|
19
|
+
children: heading ?? "All Tags"
|
|
20
|
+
}),
|
|
21
|
+
/* @__PURE__ */ jsx("p", {
|
|
22
|
+
className: "text-fd-muted-foreground empty:hidden",
|
|
23
|
+
children: description ?? /* @__PURE__ */ jsxs("span", {
|
|
24
|
+
className: "flex items-center gap-1",
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ jsx(TagIcon, { className: "size-3.5 text-fd-primary" }),
|
|
27
|
+
/* @__PURE__ */ jsx("span", {
|
|
28
|
+
className: "text-fd-primary font-mono",
|
|
29
|
+
children: grouped.size
|
|
30
|
+
}),
|
|
31
|
+
" tags in total."
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
37
|
+
className: "grid grid-cols-2 sm:grid-cols-3 gap-2 mt-4 md:grid-cols-4 xl:grid-cols-6",
|
|
38
|
+
children: Array.from(grouped.entries()).sort((a, b) => b[1] - a[1]).map(([tag, count]) => /* @__PURE__ */ jsxs(Link, {
|
|
39
|
+
to: `/blog/tags/${tag}`,
|
|
40
|
+
className: "flex flex-row items-center gap-2 bg-fd-card text-fd-card-foreground border font-mono rounded-lg px-2 py-1 transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground",
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ jsx(TagIcon, { className: "size-3.5 text-fd-muted-foreground" }),
|
|
43
|
+
/* @__PURE__ */ jsx("p", {
|
|
44
|
+
className: "font-medium",
|
|
45
|
+
children: tag
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ jsx("p", {
|
|
48
|
+
className: "ms-auto text-sm text-fd-muted-foreground",
|
|
49
|
+
children: count
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
}, tag))
|
|
53
|
+
})] });
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function createBlogTagPage({ heading, description } = {}) {
|
|
57
|
+
return async function BlogTagsPage({ lang, tag, blog, ctx }) {
|
|
58
|
+
const source = await ctx.getLoader();
|
|
59
|
+
const posts = [];
|
|
60
|
+
for (const page of source.getPages(lang)) {
|
|
61
|
+
if (!blog.isBlog.call(ctx, page)) continue;
|
|
62
|
+
const tags = await getTags(ctx, page);
|
|
63
|
+
if (!tags || !tags.includes(tag)) continue;
|
|
64
|
+
posts.push(page);
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
67
|
+
className: "flex flex-col items-start gap-4 border-y p-4 pt-3.5 bg-fd-card text-fd-card-foreground shadow-inner max-sm:-mx-4 sm:rounded-xl sm:border",
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsx(LinkToHome, {
|
|
70
|
+
lang,
|
|
71
|
+
blog
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ jsx("h1", {
|
|
74
|
+
className: "font-semibold text-2xl",
|
|
75
|
+
children: heading ?? /* @__PURE__ */ jsxs("span", {
|
|
76
|
+
className: "inline-flex gap-2 items-center",
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ jsx(TagIcon, { className: "text-fd-primary size-6" }),
|
|
79
|
+
"Tag ",
|
|
80
|
+
/* @__PURE__ */ jsxs("span", {
|
|
81
|
+
className: "font-mono text-fd-primary",
|
|
82
|
+
children: [
|
|
83
|
+
"\"",
|
|
84
|
+
tag,
|
|
85
|
+
"\""
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
})
|
|
90
|
+
}),
|
|
91
|
+
/* @__PURE__ */ jsx("p", {
|
|
92
|
+
className: "text-fd-muted-foreground empty:hidden",
|
|
93
|
+
children: description ?? /* @__PURE__ */ jsxs("span", {
|
|
94
|
+
className: "inline-flex items-center gap-1",
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsx(NewspaperIcon, { className: "text-fd-primary size-3.5" }),
|
|
97
|
+
/* @__PURE__ */ jsx("span", {
|
|
98
|
+
className: "font-mono text-fd-primary",
|
|
99
|
+
children: posts.length
|
|
100
|
+
}),
|
|
101
|
+
" matching blog posts."
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
}), /* @__PURE__ */ jsx(OrderedBlogGrid, {
|
|
107
|
+
posts,
|
|
108
|
+
ctx
|
|
109
|
+
})] });
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { createBlogTagPage, createBlogTagsPage };
|
package/dist/layouts/docs.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface DocsLayoutOptions<C extends ConfigContext = ConfigContext> {
|
|
|
14
14
|
markdownUrl?: string;
|
|
15
15
|
lastModified?: Date | null;
|
|
16
16
|
body?: ReactNode;
|
|
17
|
-
layoutProps?: TransformChildren<
|
|
17
|
+
layoutProps?: Partial<TransformChildren<DocsLayoutProps>>;
|
|
18
18
|
pageProps?: TransformChildren<DocsPageProps>;
|
|
19
19
|
}>;
|
|
20
20
|
}
|
|
@@ -30,8 +30,8 @@ interface DocsLayoutContextData {
|
|
|
30
30
|
page: Page;
|
|
31
31
|
}, data: DocsLayoutRenderData) => Awaitable<DocsLayoutRenderData>)[];
|
|
32
32
|
}
|
|
33
|
-
declare function
|
|
33
|
+
declare function createDocsLayoutPage<C extends ConfigContext = ConfigContext>({
|
|
34
34
|
render
|
|
35
35
|
}?: DocsLayoutOptions<NoInfer<C>>): Layouts<C>["page"];
|
|
36
36
|
//#endregion
|
|
37
|
-
export { DocsLayoutContextData, DocsLayoutOptions, DocsLayoutRenderData,
|
|
37
|
+
export { DocsLayoutContextData, DocsLayoutOptions, DocsLayoutRenderData, createDocsLayoutPage };
|
package/dist/layouts/docs.js
CHANGED
|
@@ -1,63 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { baseLayoutProps, createTransformChildren, getGitHubFileUrl, getLastModifiedDate, mergeLayoutConfigs, renderBody, renderPageMeta, renderToc } from "../lib/shared.js";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { unstable_notFound } from "waku/router/server";
|
|
4
3
|
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
5
4
|
import { DocsBody, DocsDescription, DocsPage, DocsTitle, MarkdownCopyButton, PageLastUpdate, ViewOptionsPopover } from "fumadocs-ui/layouts/docs/page";
|
|
6
5
|
//#region src/layouts/docs.tsx
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
body = await adapter["core:render-body"]?.call(this, page);
|
|
13
|
-
if (body !== void 0) break;
|
|
14
|
-
}
|
|
15
|
-
for (const adapter of this.adapters) {
|
|
16
|
-
toc = await adapter["core:render-toc"]?.call(this, page);
|
|
17
|
-
if (toc !== void 0) break;
|
|
18
|
-
}
|
|
19
|
-
if (body === void 0) throw new Error("[Fumapress] Please specify the `render` option in createDocsLayout()");
|
|
20
|
-
return {
|
|
21
|
-
body,
|
|
22
|
-
pageProps: { toc }
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return async function Layout(props) {
|
|
26
|
-
const { slugs, lang, getLoader, data: { "core:docs-layout": layoutData } } = props;
|
|
6
|
+
function createDocsLayoutPage({ render } = {}) {
|
|
7
|
+
const TDocsLayout = createTransformChildren(DocsLayout);
|
|
8
|
+
const TDocsPage = createTransformChildren(DocsPage);
|
|
9
|
+
return async function Layout({ lang, page, ctx }) {
|
|
10
|
+
const { getLoader, layouts, data: { "core:docs-layout": layoutData } } = ctx;
|
|
27
11
|
const source = await getLoader();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
} else result = {
|
|
44
|
-
body: _raw.body,
|
|
45
|
-
pageProps: _raw.pageProps,
|
|
46
|
-
markdownUrl: _raw.markdownUrl,
|
|
47
|
-
layoutProps: {
|
|
48
|
-
tree: source.getPageTree(lang),
|
|
49
|
-
..._raw.layoutProps ?? baseOptions(props)
|
|
50
|
-
}
|
|
12
|
+
async function getLayoutProps(overrides) {
|
|
13
|
+
const inherit = await layouts.defaultProps?.call(ctx, { lang });
|
|
14
|
+
return mergeLayoutConfigs({ tree: source.getPageTree(lang) }, baseLayoutProps(ctx), inherit, overrides);
|
|
15
|
+
}
|
|
16
|
+
const _raw = await render?.call(ctx, page);
|
|
17
|
+
let result = {
|
|
18
|
+
..._raw,
|
|
19
|
+
lastModified: _raw?.lastModified ?? await getLastModifiedDate(ctx, page),
|
|
20
|
+
pageProps: {
|
|
21
|
+
..._raw?.pageProps,
|
|
22
|
+
toc: _raw?.pageProps?.toc ?? await renderToc(ctx, page)
|
|
23
|
+
},
|
|
24
|
+
body: _raw?.body ?? await renderBody(ctx, page, "[Fumapress] Please specify the `render` option in createDocsLayoutPage()"),
|
|
25
|
+
layoutProps: await getLayoutProps(_raw?.layoutProps)
|
|
51
26
|
};
|
|
52
27
|
if (layoutData?.renderers) {
|
|
53
28
|
const renderCtx = { page };
|
|
54
29
|
for (const r of layoutData.renderers) result = await r.call(renderCtx, result);
|
|
55
30
|
}
|
|
56
|
-
return /* @__PURE__ */ jsxs(
|
|
57
|
-
Comp: DocsLayout,
|
|
31
|
+
return /* @__PURE__ */ jsxs(TDocsLayout, {
|
|
58
32
|
props: result.layoutProps,
|
|
59
|
-
children: [renderPageMeta(page,
|
|
60
|
-
Comp: DocsPage,
|
|
33
|
+
children: [renderPageMeta(page, ctx), /* @__PURE__ */ jsxs(TDocsPage, {
|
|
61
34
|
props: result.pageProps,
|
|
62
35
|
children: [
|
|
63
36
|
/* @__PURE__ */ jsx(DocsTitle, { children: page.data.title }),
|
|
@@ -69,7 +42,7 @@ function createDocsLayout({ render } = {}) {
|
|
|
69
42
|
className: "flex flex-row gap-2 items-center border-b pt-2 pb-6",
|
|
70
43
|
children: [result.markdownUrl && /* @__PURE__ */ jsx(MarkdownCopyButton, { markdownUrl: result.markdownUrl }), /* @__PURE__ */ jsx(ViewOptionsPopover, {
|
|
71
44
|
markdownUrl: result.markdownUrl,
|
|
72
|
-
githubUrl: page.absolutePath ? getGitHubFileUrl(
|
|
45
|
+
githubUrl: page.absolutePath ? getGitHubFileUrl(ctx, page.absolutePath) : void 0
|
|
73
46
|
})]
|
|
74
47
|
}),
|
|
75
48
|
/* @__PURE__ */ jsx(DocsBody, { children: result.body }),
|
|
@@ -80,4 +53,4 @@ function createDocsLayout({ render } = {}) {
|
|
|
80
53
|
};
|
|
81
54
|
}
|
|
82
55
|
//#endregion
|
|
83
|
-
export {
|
|
56
|
+
export { createDocsLayoutPage };
|
package/dist/layouts/home.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { AppContext, TransformChildren } from "../lib/shared.js";
|
|
2
2
|
import { ConfigContext, Layouts } from "../config.js";
|
|
3
3
|
import { Awaitable } from "../lib/types.js";
|
|
4
|
-
import { ReactNode } from "react";
|
|
4
|
+
import { ComponentType, ReactNode } from "react";
|
|
5
5
|
import { HomeLayoutProps } from "fumadocs-ui/layouts/home";
|
|
6
6
|
import { Page } from "fumadocs-core/source";
|
|
7
7
|
|
|
8
8
|
//#region src/layouts/home.d.ts
|
|
9
|
-
interface
|
|
9
|
+
interface HomeLayoutPageOptions<C extends ConfigContext = ConfigContext> {
|
|
10
10
|
render?: (this: AppContext<C>, page: C["loaderConfig"]["page"]) => Awaitable<{
|
|
11
11
|
body?: ReactNode;
|
|
12
|
-
layoutProps?: TransformChildren<
|
|
12
|
+
layoutProps?: TransformChildren<HomeLayoutProps>;
|
|
13
13
|
}>;
|
|
14
14
|
}
|
|
15
15
|
interface HomeLayoutRenderData {
|
|
@@ -18,11 +18,23 @@ interface HomeLayoutRenderData {
|
|
|
18
18
|
}
|
|
19
19
|
interface HomeLayoutContextData {
|
|
20
20
|
renderers?: ((this: {
|
|
21
|
-
page: Page;
|
|
21
|
+
page: Page | undefined;
|
|
22
22
|
}, data: HomeLayoutRenderData) => Awaitable<HomeLayoutRenderData>)[];
|
|
23
23
|
}
|
|
24
|
+
declare function createHomeLayoutPage<C extends ConfigContext = ConfigContext>({
|
|
25
|
+
render
|
|
26
|
+
}?: HomeLayoutPageOptions<NoInfer<C>>): Layouts<C>["page"];
|
|
27
|
+
interface HomeLayoutOptions<C extends ConfigContext = ConfigContext> {
|
|
28
|
+
render?: (this: AppContext<C>) => Awaitable<{
|
|
29
|
+
layoutProps?: TransformChildren<HomeLayoutProps>;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
24
32
|
declare function createHomeLayout<C extends ConfigContext = ConfigContext>({
|
|
25
33
|
render
|
|
26
|
-
}
|
|
34
|
+
}?: HomeLayoutOptions<C>): ComponentType<{
|
|
35
|
+
lang?: string;
|
|
36
|
+
children: ReactNode;
|
|
37
|
+
ctx: AppContext<C>;
|
|
38
|
+
}>;
|
|
27
39
|
//#endregion
|
|
28
|
-
export { HomeLayoutContextData, HomeLayoutOptions, HomeLayoutRenderData, createHomeLayout };
|
|
40
|
+
export { HomeLayoutContextData, HomeLayoutOptions, HomeLayoutPageOptions, HomeLayoutRenderData, createHomeLayout, createHomeLayoutPage };
|
package/dist/layouts/home.js
CHANGED
|
@@ -1,35 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { unstable_notFound } from "waku/router/server";
|
|
1
|
+
import { baseLayoutProps, createTransformChildren, mergeLayoutConfigs, renderBody, renderPageMeta } from "../lib/shared.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
3
|
import { HomeLayout } from "fumadocs-ui/layouts/home";
|
|
5
4
|
//#region src/layouts/home.tsx
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
function createHomeLayoutPage({ render } = {}) {
|
|
6
|
+
const THomeLayout = createTransformChildren(HomeLayout);
|
|
7
|
+
return async function Layout({ lang, page, ctx }) {
|
|
8
|
+
const { layouts, data: { "core:home-layout": layoutData } } = ctx;
|
|
9
|
+
async function getLayoutProps(overrides) {
|
|
10
|
+
const inherit = await layouts.defaultProps?.call(ctx, { lang });
|
|
11
|
+
return mergeLayoutConfigs(baseLayoutProps(ctx), inherit, overrides);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
return async function Layout(props) {
|
|
15
|
-
const { slugs, lang, getLoader, data: { "core:home-layout": layoutData } } = props;
|
|
16
|
-
const page = (await getLoader()).getPage(slugs, lang);
|
|
17
|
-
if (!page) unstable_notFound();
|
|
18
|
-
const _raw = await (render ?? renderDefault).call(props, page);
|
|
13
|
+
const _raw = await render?.call(ctx, page);
|
|
19
14
|
let result = {
|
|
20
|
-
body: _raw
|
|
21
|
-
layoutProps: _raw
|
|
15
|
+
body: _raw?.body ?? await renderBody(ctx, page, "[Fumapress] Please specify the `render` option in createHomeLayoutPage()"),
|
|
16
|
+
layoutProps: await getLayoutProps(_raw?.layoutProps)
|
|
22
17
|
};
|
|
23
18
|
if (layoutData?.renderers) {
|
|
24
19
|
const renderCtx = { page };
|
|
25
20
|
for (const r of layoutData.renderers) result = await r.call(renderCtx, result);
|
|
26
21
|
}
|
|
27
|
-
return /* @__PURE__ */ jsxs(
|
|
28
|
-
Comp: HomeLayout,
|
|
22
|
+
return /* @__PURE__ */ jsxs(THomeLayout, {
|
|
29
23
|
props: result.layoutProps,
|
|
30
|
-
children: [renderPageMeta(page,
|
|
24
|
+
children: [renderPageMeta(page, ctx), result.body]
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function createHomeLayout({ render } = {}) {
|
|
29
|
+
const THomeLayout = createTransformChildren(HomeLayout);
|
|
30
|
+
return async function Layout({ lang, children, ctx }) {
|
|
31
|
+
const { layouts, data: { "core:home-layout": layoutData } } = ctx;
|
|
32
|
+
async function getLayoutProps(overrides) {
|
|
33
|
+
const inherit = await layouts.defaultProps?.call(ctx, { lang });
|
|
34
|
+
return mergeLayoutConfigs(baseLayoutProps(ctx), inherit, overrides);
|
|
35
|
+
}
|
|
36
|
+
let result = {
|
|
37
|
+
body: children,
|
|
38
|
+
layoutProps: await getLayoutProps((await render?.call(ctx))?.layoutProps)
|
|
39
|
+
};
|
|
40
|
+
if (layoutData?.renderers) {
|
|
41
|
+
const renderCtx = { page: void 0 };
|
|
42
|
+
for (const r of layoutData.renderers) result = await r.call(renderCtx, result);
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsx(THomeLayout, {
|
|
45
|
+
props: result.layoutProps,
|
|
46
|
+
children: result.body
|
|
31
47
|
});
|
|
32
48
|
};
|
|
33
49
|
}
|
|
34
50
|
//#endregion
|
|
35
|
-
export { createHomeLayout };
|
|
51
|
+
export { createHomeLayout, createHomeLayoutPage };
|
|
@@ -14,7 +14,7 @@ interface NotebookLayoutOptions<C extends ConfigContext = ConfigContext> {
|
|
|
14
14
|
markdownUrl?: string;
|
|
15
15
|
lastModified?: Date | null;
|
|
16
16
|
body?: ReactNode;
|
|
17
|
-
layoutProps?: TransformChildren<
|
|
17
|
+
layoutProps?: Partial<TransformChildren<DocsLayoutProps>>;
|
|
18
18
|
pageProps?: TransformChildren<DocsPageProps>;
|
|
19
19
|
}>;
|
|
20
20
|
}
|
|
@@ -30,8 +30,8 @@ interface NotebookLayoutContextData {
|
|
|
30
30
|
page: Page;
|
|
31
31
|
}, data: NotebookLayoutRenderData) => Awaitable<NotebookLayoutRenderData>)[];
|
|
32
32
|
}
|
|
33
|
-
declare function
|
|
33
|
+
declare function createNotebookLayoutPage<C extends ConfigContext = ConfigContext>({
|
|
34
34
|
render
|
|
35
35
|
}?: NotebookLayoutOptions<NoInfer<C>>): Layouts<C>["page"];
|
|
36
36
|
//#endregion
|
|
37
|
-
export { NotebookLayoutContextData, NotebookLayoutOptions, NotebookLayoutRenderData,
|
|
37
|
+
export { NotebookLayoutContextData, NotebookLayoutOptions, NotebookLayoutRenderData, createNotebookLayoutPage };
|
package/dist/layouts/notebook.js
CHANGED
|
@@ -1,63 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { baseLayoutProps, createTransformChildren, getGitHubFileUrl, getLastModifiedDate, mergeLayoutConfigs, renderBody, renderPageMeta, renderToc } from "../lib/shared.js";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { unstable_notFound } from "waku/router/server";
|
|
4
3
|
import { DocsLayout } from "fumadocs-ui/layouts/notebook";
|
|
5
4
|
import { DocsBody, DocsDescription, DocsPage, DocsTitle, MarkdownCopyButton, PageLastUpdate, ViewOptionsPopover } from "fumadocs-ui/layouts/notebook/page";
|
|
6
5
|
//#region src/layouts/notebook.tsx
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
body = await adapter["core:render-body"]?.call(this, page);
|
|
13
|
-
if (body !== void 0) break;
|
|
14
|
-
}
|
|
15
|
-
for (const adapter of this.adapters) {
|
|
16
|
-
toc = await adapter["core:render-toc"]?.call(this, page);
|
|
17
|
-
if (toc !== void 0) break;
|
|
18
|
-
}
|
|
19
|
-
if (body === void 0) throw new Error("[Fumapress] Please specify the `render` option in createNotebookLayout()");
|
|
20
|
-
return {
|
|
21
|
-
body,
|
|
22
|
-
pageProps: { toc }
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return async function Layout(props) {
|
|
26
|
-
const { slugs, lang, getLoader, data: { "core:notebook-layout": layoutData } } = props;
|
|
6
|
+
function createNotebookLayoutPage({ render } = {}) {
|
|
7
|
+
const TDocsLayout = createTransformChildren(DocsLayout);
|
|
8
|
+
const TDocsPage = createTransformChildren(DocsPage);
|
|
9
|
+
return async function Layout({ lang, page, ctx }) {
|
|
10
|
+
const { getLoader, layouts, data: { "core:notebook-layout": layoutData } } = ctx;
|
|
27
11
|
const source = await getLoader();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
} else result = {
|
|
44
|
-
body: _raw.body,
|
|
45
|
-
pageProps: _raw.pageProps,
|
|
46
|
-
markdownUrl: _raw.markdownUrl,
|
|
47
|
-
layoutProps: {
|
|
48
|
-
tree: source.getPageTree(lang),
|
|
49
|
-
..._raw.layoutProps ?? baseOptions(props)
|
|
50
|
-
}
|
|
12
|
+
async function getLayoutProps(overrides) {
|
|
13
|
+
const inherit = await layouts.defaultProps?.call(ctx, { lang });
|
|
14
|
+
return mergeLayoutConfigs({ tree: source.getPageTree(lang) }, baseLayoutProps(ctx), inherit, overrides);
|
|
15
|
+
}
|
|
16
|
+
const _raw = await render?.call(ctx, page);
|
|
17
|
+
let result = {
|
|
18
|
+
..._raw,
|
|
19
|
+
lastModified: _raw?.lastModified ?? await getLastModifiedDate(ctx, page),
|
|
20
|
+
pageProps: {
|
|
21
|
+
..._raw?.pageProps,
|
|
22
|
+
toc: _raw?.pageProps?.toc ?? await renderToc(ctx, page)
|
|
23
|
+
},
|
|
24
|
+
body: _raw?.body ?? await renderBody(ctx, page, "[Fumapress] Please specify the `render` option in createNotebookLayoutPage()"),
|
|
25
|
+
layoutProps: await getLayoutProps(_raw?.layoutProps)
|
|
51
26
|
};
|
|
52
27
|
if (layoutData?.renderers) {
|
|
53
28
|
const renderCtx = { page };
|
|
54
29
|
for (const r of layoutData.renderers) result = await r.call(renderCtx, result);
|
|
55
30
|
}
|
|
56
|
-
return /* @__PURE__ */ jsxs(
|
|
57
|
-
Comp: DocsLayout,
|
|
31
|
+
return /* @__PURE__ */ jsxs(TDocsLayout, {
|
|
58
32
|
props: result.layoutProps,
|
|
59
|
-
children: [renderPageMeta(page,
|
|
60
|
-
Comp: DocsPage,
|
|
33
|
+
children: [renderPageMeta(page, ctx), /* @__PURE__ */ jsxs(TDocsPage, {
|
|
61
34
|
props: result.pageProps,
|
|
62
35
|
children: [
|
|
63
36
|
/* @__PURE__ */ jsx(DocsTitle, { children: page.data.title }),
|
|
@@ -69,7 +42,7 @@ function createNotebookLayout({ render } = {}) {
|
|
|
69
42
|
className: "flex flex-row gap-2 items-center border-b pt-2 pb-6",
|
|
70
43
|
children: [result.markdownUrl && /* @__PURE__ */ jsx(MarkdownCopyButton, { markdownUrl: result.markdownUrl }), /* @__PURE__ */ jsx(ViewOptionsPopover, {
|
|
71
44
|
markdownUrl: result.markdownUrl,
|
|
72
|
-
githubUrl: page.absolutePath ? getGitHubFileUrl(
|
|
45
|
+
githubUrl: page.absolutePath ? getGitHubFileUrl(ctx, page.absolutePath) : void 0
|
|
73
46
|
})]
|
|
74
47
|
}),
|
|
75
48
|
/* @__PURE__ */ jsx(DocsBody, { children: result.body }),
|
|
@@ -80,4 +53,4 @@ function createNotebookLayout({ render } = {}) {
|
|
|
80
53
|
};
|
|
81
54
|
}
|
|
82
55
|
//#endregion
|
|
83
|
-
export {
|
|
56
|
+
export { createNotebookLayoutPage };
|
package/dist/layouts/root.js
CHANGED
|
@@ -4,12 +4,11 @@ import styles from "virtual:root.css?inline";
|
|
|
4
4
|
import { RootProvider } from "fumadocs-ui/provider/waku";
|
|
5
5
|
//#region src/layouts/root.tsx
|
|
6
6
|
function createRootLayout(options) {
|
|
7
|
-
return async function(
|
|
8
|
-
const
|
|
9
|
-
const hooks = data["core:provider"];
|
|
7
|
+
return async function({ lang, ctx, children }) {
|
|
8
|
+
const hooks = ctx.data["core:provider"];
|
|
10
9
|
let providerProps = { ...options?.providerProps };
|
|
11
|
-
if (i18nConfig) {
|
|
12
|
-
const { languages } = i18nConfig;
|
|
10
|
+
if (ctx.i18nConfig) {
|
|
11
|
+
const { languages } = ctx.i18nConfig;
|
|
13
12
|
providerProps.i18n ??= {
|
|
14
13
|
locale: lang,
|
|
15
14
|
locales: Object.entries(languages).map(([k, v]) => ({
|
|
@@ -23,7 +22,7 @@ function createRootLayout(options) {
|
|
|
23
22
|
return /* @__PURE__ */ jsxs("html", {
|
|
24
23
|
lang: lang ?? "en",
|
|
25
24
|
suppressHydrationWarning: true,
|
|
26
|
-
children: [/* @__PURE__ */ jsxs("head", { children: [/* @__PURE__ */ jsx("style", { children: styles }), renderRootMeta(
|
|
25
|
+
children: [/* @__PURE__ */ jsxs("head", { children: [/* @__PURE__ */ jsx("style", { children: styles }), renderRootMeta(ctx)] }), /* @__PURE__ */ jsx("body", {
|
|
27
26
|
"data-version": "1.0",
|
|
28
27
|
className: "flex flex-col min-h-screen",
|
|
29
28
|
children: /* @__PURE__ */ jsx(RootProvider, {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AppContext } from "../lib/shared.js";
|
|
2
|
+
import { ConfigContext, Layouts } from "../config.js";
|
|
3
|
+
import { Page } from "fumadocs-core/source";
|
|
4
|
+
|
|
5
|
+
//#region src/layouts/switch.d.ts
|
|
6
|
+
declare function createLayoutSwitchAuto<C extends ConfigContext = ConfigContext>(layouts: Record<C["loaderConfig"]["page"] extends Page<infer Type extends string> ? Type : never, Layouts<C>["page"]>): Layouts<C>["page"];
|
|
7
|
+
declare function createLayoutSwitch<T extends string, C extends ConfigContext = ConfigContext>(/** detect layout from page */
|
|
8
|
+
|
|
9
|
+
detector: (this: AppContext<C>, page: C["loaderConfig"]["page"]) => T, layouts: Record<NoInfer<T>, Layouts<C>["page"]>): Layouts<C>["page"];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { createLayoutSwitch, createLayoutSwitchAuto };
|