Skip to content

Commit 8f2c2b0

Browse files
committed
refactor(docs): use nextra + next
1 parent 78258fc commit 8f2c2b0

File tree

23 files changed

+7107
-1059
lines changed

23 files changed

+7107
-1059
lines changed

.github/workflows/deploy-pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ jobs:
4545
- name: Setup pages
4646
uses: actions/configure-pages@v5
4747

48-
- name: Build docs
48+
- name: Build docs with Next.js
4949
working-directory: saltify-docs
5050
run: pnpm build
5151

5252
- name: Upload Pages artifact
5353
uses: actions/upload-pages-artifact@v3
5454
with:
55-
path: saltify-docs/.vitepress/dist
55+
path: saltify-docs/out
5656

5757
deploy:
5858
needs: build

saltify-docs/.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
.vitepress/cache
1+
# Next.js
2+
.next/
3+
out/
4+
*.tsbuildinfo
5+
6+
# Dependencies
7+
node_modules/

saltify-docs/.vitepress/config.mts

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { generateStaticParamsFor, importPage } from 'nextra/pages';
2+
import { useMDXComponents as getMDXComponents } from '../../mdx-components';
3+
import { Metadata } from 'next';
4+
5+
export const generateStaticParams = generateStaticParamsFor('mdxPath');
6+
7+
type Props = {
8+
params: Promise<{ slug: string; mdxPath: string[] }>;
9+
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
10+
};
11+
12+
export async function generateMetadata(props: Props): Promise<Metadata> {
13+
const params = await props.params;
14+
const { metadata } = await importPage(params.mdxPath);
15+
return {
16+
...metadata,
17+
title: metadata.title ? `Saltify | ${metadata.title}` : 'Saltify 文档',
18+
};
19+
}
20+
21+
const Wrapper = getMDXComponents().wrapper;
22+
23+
export default async function Page(props: Props) {
24+
const params = await props.params;
25+
const { default: MDXContent, toc, metadata } = await importPage(params.mdxPath);
26+
return (
27+
<Wrapper toc={toc} metadata={metadata}>
28+
<MDXContent {...props} params={params} />
29+
</Wrapper>
30+
);
31+
}

saltify-docs/app/layout.tsx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { Footer, LastUpdated, Layout, Navbar } from 'nextra-theme-docs';
2+
import { getPageMap } from 'nextra/page-map';
3+
import 'nextra-theme-docs/style.css';
4+
import './styles.css';
5+
import { Head, Search } from 'nextra/components';
6+
import { Metadata } from 'next';
7+
8+
export const metadata: Metadata = {
9+
title: 'Saltify 文档',
10+
description: '跨平台、可扩展的 QQ Bot 框架 & Milky SDK',
11+
};
12+
13+
export default async function RootLayout({ children }: { children: React.ReactNode }) {
14+
return (
15+
<html lang="zh" suppressHydrationWarning>
16+
<Head />
17+
<body>
18+
<Layout
19+
navbar={
20+
<Navbar
21+
logo={
22+
<div style={{ fontSize: '1.15rem' }}>
23+
<b>Saltify</b> 文档
24+
</div>
25+
}
26+
projectLink={'https://github.com/SaltifyDev/saltify'}
27+
></Navbar>
28+
}
29+
pageMap={await getPageMap()}
30+
docsRepositoryBase="https://github.com/SaltifyDev/saltify/tree/main/saltify-docs"
31+
search={
32+
<Search
33+
placeholder="搜索内容..."
34+
emptyResult="没有找到相关内容"
35+
errorText="加载索引失败"
36+
loading="加载中..."
37+
/>
38+
}
39+
editLink="在 GitHub 上编辑此页"
40+
feedback={{
41+
content: '有问题?提交反馈',
42+
labels: 'documentation',
43+
}}
44+
lastUpdated={<LastUpdated locale="zh">最后更新于</LastUpdated>}
45+
themeSwitch={{
46+
dark: '暗色',
47+
light: '亮色',
48+
system: '跟随系统',
49+
}}
50+
toc={{
51+
title: '目录',
52+
backToTop: '返回顶部',
53+
}}
54+
>
55+
{children}
56+
<Footer>
57+
© {new Date().getFullYear()} SaltifyDev. Licensed under MIT.
58+
</Footer>
59+
</Layout>
60+
</body>
61+
</html>
62+
);
63+
}

saltify-docs/app/nextra.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'nextra' {
2+
export * from 'nextra/types';
3+
}

saltify-docs/app/styles.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
code, kbd, samp, pre {
2+
font-family: SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
3+
}
4+
5+
code.nextra-code {
6+
font-size: 1em;
7+
}

saltify-docs/content/_meta.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { MetaRecord } from 'nextra';
2+
3+
export default {
4+
index: '快速开始',
5+
'docs-core': 'saltify-core 文档',
6+
} satisfies MetaRecord;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { MetaRecord } from 'nextra';
2+
3+
export default {
4+
application: '应用配置',
5+
plugin: '插件开发',
6+
command: '指令开发',
7+
logging: '日志实现',
8+
} satisfies MetaRecord;
File renamed without changes.

0 commit comments

Comments
 (0)