Skip to content

Commit 55ac596

Browse files
committed
use fumadocs
1 parent 73f708f commit 55ac596

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4928
-3962
lines changed

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "next/typescript"]
3+
}

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,31 @@ node_modules
33
.vuepress/dist
44
.cache/
55
.temp/
6+
# deps
7+
/node_modules
8+
9+
# generated content
10+
.contentlayer
11+
.content-collections
12+
.source
13+
14+
# test & build
15+
/coverage
16+
/.next/
17+
/out/
18+
/build
19+
*.tsbuildinfo
20+
21+
# misc
22+
.DS_Store
23+
*.pem
24+
/.pnp
25+
.pnp.js
26+
npm-debug.log*
27+
yarn-debug.log*
28+
yarn-error.log*
29+
30+
# others
31+
.env*.local
32+
.vercel
33+
next-env.d.ts

api/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/(home)/layout.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { ReactNode } from 'react';
2+
import { HomeLayout } from 'fumadocs-ui/layouts/home';
3+
import { baseOptions } from '@/app/layout.config';
4+
5+
export default function Layout({ children }: { children: ReactNode }) {
6+
return <HomeLayout {...baseOptions}>{children}dsa</HomeLayout>;
7+
}

app/(home)/page.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Link from 'next/link';
2+
3+
export default function HomePage() {
4+
return (
5+
<main className="flex flex-1 flex-col justify-center text-center">
6+
<h1 className="mb-4 text-2xl font-bold">Hello World</h1>
7+
<p className="text-fd-muted-foreground">
8+
You can open{' '}
9+
<Link
10+
href="/docs"
11+
className="text-fd-foreground font-semibold underline"
12+
>
13+
/docs
14+
</Link>{' '}
15+
and see the documentation.
16+
</p>
17+
</main>
18+
);
19+
}

app/api/search/route.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { source } from '@/lib/source';
2+
import { createFromSource } from 'fumadocs-core/search/server';
3+
import { createTokenizer } from '@orama/tokenizers/mandarin';
4+
import { stopwords as mandarinStopwords } from "@orama/stopwords/mandarin";
5+
6+
export const revalidate = false;
7+
8+
const tokenizer = createTokenizer({
9+
stopWords: mandarinStopwords,
10+
});
11+
const search = {
12+
tokenizer,
13+
language: 'mandarin',
14+
components: {
15+
tokenizer,
16+
},
17+
search: {
18+
threshold: 0,
19+
tolerance: 0,
20+
},
21+
}
22+
export const { staticGET: GET } = createFromSource(source, undefined, {
23+
localeMap: {
24+
cn: search,
25+
en: search,
26+
mandarin: search,
27+
english: search,
28+
}
29+
});

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { source } from '@/lib/source';
2+
import { Popup, PopupContent, PopupTrigger } from 'fumadocs-twoslash/ui';
3+
import { Callout } from 'fumadocs-ui/components/callout';
4+
import {
5+
DocsPage,
6+
DocsBody,
7+
DocsDescription,
8+
DocsTitle,
9+
} from 'fumadocs-ui/page';
10+
import { notFound } from 'next/navigation';
11+
import defaultMdxComponents from 'fumadocs-ui/mdx';
12+
13+
export default async function Page(props: {
14+
params: Promise<{ slug?: string[] }>;
15+
}) {
16+
const params = await props.params;
17+
const page = source.getPage(params.slug);
18+
if (!page) notFound();
19+
20+
const MDX = page.data.body;
21+
22+
return (
23+
<DocsPage toc={page.data.toc} full={page.data.full}>
24+
<DocsTitle>{page.data.title}</DocsTitle>
25+
<DocsDescription>{page.data.description}</DocsDescription>
26+
<DocsBody>
27+
<MDX components={{
28+
...defaultMdxComponents,
29+
Popup,
30+
PopupContent,
31+
PopupTrigger,
32+
Callout,
33+
}} />
34+
</DocsBody>
35+
</DocsPage>
36+
);
37+
}
38+
39+
export async function generateStaticParams() {
40+
return source.generateParams();
41+
}
42+
43+
export async function generateMetadata(props: {
44+
params: Promise<{ slug?: string[] }>;
45+
}) {
46+
const params = await props.params;
47+
const page = source.getPage(params.slug);
48+
if (!page) notFound();
49+
50+
return {
51+
title: page.data.title,
52+
description: page.data.description,
53+
};
54+
}

app/docs/layout.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
2+
import { RootToggle } from 'fumadocs-ui/components/layout/root-toggle';
3+
import type { ReactNode } from 'react';
4+
import { baseOptions } from '@/app/layout.config';
5+
import { source } from '@/lib/source';
6+
7+
export default function Layout({ children }: { children: ReactNode }) {
8+
return (
9+
<DocsLayout
10+
tree={source.pageTree}
11+
{...baseOptions}
12+
sidebar={{
13+
tabs: false,
14+
banner: (
15+
<RootToggle
16+
options={[
17+
{
18+
title: 'Hydro',
19+
description: 'The Online Judge System',
20+
url: '/docs/Hydro',
21+
},
22+
{
23+
title: 'XCPC-Tools',
24+
description: 'Tools for on-site contests',
25+
url: '/docs/Tools',
26+
},
27+
]}
28+
/>
29+
),
30+
}}
31+
>
32+
{children}
33+
</DocsLayout>
34+
);
35+
}

app/global.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import 'tailwindcss';
2+
@import 'fumadocs-ui/css/neutral.css';
3+
@import 'fumadocs-ui/css/preset.css';
4+
5+
@source '../node_modules/fumadocs-ui/dist/**/*.js';

app/layout.config.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
2+
import Image from 'next/image';
3+
4+
/**
5+
* Shared layout configurations
6+
*
7+
* you can customise layouts individually from:
8+
* Home Layout: app/(home)/layout.tsx
9+
* Docs Layout: app/docs/layout.tsx
10+
*/
11+
export const baseOptions: BaseLayoutProps = {
12+
nav: {
13+
title: (
14+
<>
15+
<Image
16+
width="24"
17+
height="24"
18+
src="https://hydro.ac/favicon.svg"
19+
alt="Logo"
20+
/>
21+
Hydro
22+
</>
23+
),
24+
},
25+
links: [
26+
],
27+
};

0 commit comments

Comments
 (0)