Skip to content

Commit 743aec6

Browse files
committed
feat: upgrade nextra
1 parent 0c66c1c commit 743aec6

39 files changed

+7025
-710
lines changed

docs/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ node_modules
44
yarn-error.log
55
dist
66
examples
7-
packages
7+
packages
8+
public

docs/app/[[...mdxPath]]/page.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { generateStaticParamsFor, importPage } from 'nextra/pages';
2+
import { useMDXComponents } from '../../mdx-components';
3+
4+
export const generateStaticParams = generateStaticParamsFor('mdxPath');
5+
6+
interface PageProps {
7+
params: Promise<{
8+
mdxPath: string[];
9+
}>;
10+
}
11+
12+
export async function generateMetadata(props: PageProps) {
13+
const params = await props.params;
14+
const { metadata } = await importPage(params.mdxPath);
15+
return metadata;
16+
}
17+
18+
export default async function Page(props: PageProps) {
19+
const params = await props.params;
20+
const result = await importPage(params.mdxPath);
21+
const { default: MDXContent, toc, metadata } = result;
22+
const Wrapper = useMDXComponents().wrapper;
23+
24+
return (
25+
<Wrapper toc={toc} metadata={metadata} sourceCode={result.sourceCode}>
26+
<MDXContent {...props} params={params} />
27+
</Wrapper>
28+
);
29+
}

docs/app/layout.tsx

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { GoogleAnalytics } from '@next/third-parties/google';
2+
import { Footer, Layout, Navbar } from 'nextra-theme-docs';
3+
import { Head } from 'nextra/components';
4+
import { getPageMap } from 'nextra/page-map';
5+
import 'nextra-theme-docs/style.css';
6+
import '../styles.css';
7+
8+
export const metadata = {
9+
title: {
10+
default: 'Redi',
11+
template: '%s – Redi',
12+
},
13+
description:
14+
'A light-weight dependency injection library for TypeScript and JavaScript',
15+
icons: {
16+
icon: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">💉</text></svg>',
17+
},
18+
openGraph: {
19+
title: 'Redi',
20+
description: 'A light-weight dependency injection library',
21+
},
22+
};
23+
24+
const logo = <span style={{ fontWeight: 800 }}>Redi</span>;
25+
26+
const navbar = (
27+
<Navbar logo={logo} projectLink="https://github.com/wzhudev/redi" />
28+
);
29+
30+
const currentYear = new Date().getFullYear();
31+
32+
const footer = (
33+
<Footer>
34+
{`MIT ${currentYear} © `}
35+
<a href="https://wzhu.dev" target="_blank" rel="noreferrer">
36+
wzhudev
37+
</a>
38+
.
39+
</Footer>
40+
);
41+
42+
export default async function RootLayout({
43+
children,
44+
}: {
45+
children: React.ReactNode;
46+
}) {
47+
return (
48+
<html lang="en" dir="ltr" suppressHydrationWarning>
49+
<Head />
50+
<body>
51+
<Layout
52+
navbar={navbar}
53+
pageMap={await getPageMap()}
54+
docsRepositoryBase="https://github.com/wzhudev/redi/tree/main/docs"
55+
footer={footer}
56+
toc={{ backToTop: true }}
57+
>
58+
{children}
59+
</Layout>
60+
<GoogleAnalytics gaId="G-6NKSQS3F6L" />
61+
</body>
62+
</html>
63+
);
64+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
export default {
2+
index: {
3+
title: 'Home',
4+
type: 'page',
5+
},
26
docs: {
37
title: 'Guides',
48
type: 'page',
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)