Skip to content

Commit 21fe230

Browse files
authored
Merge pull request #69 from code0-tech/62-migrate-to-fumadocs
Start migration to fumadocs
2 parents c348369 + d83b414 commit 21fe230

Some content is hidden

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

43 files changed

+3694
-5430
lines changed

.gitignore

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
.idea/
2-
projects/*
3-
!projects/docs-landing-page/
4-
tmp/
2+
content/*
3+
!content/code0
4+
!content/meta.json
55

6-
# build output
7-
dist/
8-
# generated types
9-
.astro/
6+
# deps
7+
/node_modules
108

11-
# dependencies
12-
node_modules/
9+
# generated content
10+
.contentlayer
11+
.content-collections
12+
/.source
1313

14-
# logs
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
1526
npm-debug.log*
1627
yarn-debug.log*
1728
yarn-error.log*
18-
pnpm-debug.log*
19-
2029

21-
# environment variables
22-
.env
23-
.env.production
24-
25-
# macOS-specific files
26-
.DS_Store
30+
# others
31+
.env*.local
32+
.vercel
33+
next-env.d.ts

.gitlab-ci.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@
33
script:
44
- npm ci
55
- ./clone_projects.sh
6-
- ./build.sh
6+
- npm run build
77

88
build:
99
extends:
1010
- .build
1111
stage: build
12-
variables:
13-
C0_GLOBAL_BASE: /-/development/telescopium/-/jobs/$CI_JOB_ID/artifacts/dist
14-
after_script:
15-
- node scripts/local_link_suffixer.js
16-
- |
17-
echo -e "\e[0Ksection_start:`date +%s`:glpa_summary\r\e[0KHeader of the summary"
18-
echo "Documentation preview available at https://code0-tech.gitlab.io${C0_GLOBAL_BASE}/index.html"
19-
echo -e "\e[0Ksection_end:`date +%s`:glpa_summary\r\e[0K"
20-
artifacts:
21-
paths:
22-
- dist
23-
expire_in: 7 days
2412
rules:
2513
- if: ($CI_COMMIT_BRANCH != "build-branch" || $C0_TRIGGER_REF != "refs/heads/main") && $C0_TRIGGER_REF != "refs/heads/main"
2614

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nodejs 20.16.0
1+
nodejs 22

.vscode/extensions.json

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

.vscode/launch.json

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

app/(home)/layout.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type {ReactNode} from 'react';
2+
3+
export default function Layout({children}: { children: ReactNode }) {
4+
return (
5+
<html lang="en" suppressHydrationWarning>
6+
<head>
7+
<meta httpEquiv={"refresh"} content={"0; URL=code0"}/>
8+
</head>
9+
<body>
10+
{children}
11+
</body>
12+
</html>
13+
);
14+
}

app/(home)/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function HomePage() {
2+
return <span/>;
3+
}

app/[...slug]/layout.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import '../global.css';
2+
import {RootProvider} from 'fumadocs-ui/provider';
3+
import {Inter} from 'next/font/google';
4+
import type {ReactNode} from 'react';
5+
import {source} from "@/lib/source";
6+
import {baseOptions} from "@/app/layout.config";
7+
import {DocsLayout} from "fumadocs-ui/layouts/docs";
8+
9+
const inter = Inter({
10+
subsets: ['latin'],
11+
});
12+
13+
export default function Layout({children}: { children: ReactNode }) {
14+
return (
15+
<html lang="en" className={inter.className} suppressHydrationWarning>
16+
<body className="flex flex-col min-h-screen">
17+
<RootProvider search={{
18+
options: {
19+
type: 'static',
20+
},
21+
}}>
22+
<DocsLayout tree={source.pageTree} {...baseOptions}>
23+
{children}
24+
</DocsLayout>
25+
</RootProvider>
26+
</body>
27+
</html>
28+
);
29+
}

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import {source} from '@/lib/source';
2+
import {
3+
DocsPage,
4+
DocsBody,
5+
DocsDescription,
6+
DocsTitle,
7+
} from 'fumadocs-ui/page';
8+
import {notFound} from 'next/navigation';
9+
import {createRelativeLink} from 'fumadocs-ui/mdx';
10+
import {getMDXComponents} from '@/mdx-components';
11+
import type {LoaderConfig, LoaderOutput, Page} from 'fumadocs-core/source';
12+
import type {ComponentProps, FC} from 'react';
13+
14+
export default async function Page(props: {
15+
params: Promise<{ slug?: string[] }>;
16+
}) {
17+
const params = await props.params;
18+
const page = source.getPage(params.slug);
19+
if (!page) notFound();
20+
21+
const MDXContent = page.data.body;
22+
23+
return (
24+
<DocsPage toc={page.data.toc} full={page.data.full} tableOfContent={{
25+
style: 'clerk',
26+
single: false,
27+
}}>
28+
<DocsTitle>{page.data.title}</DocsTitle>
29+
<DocsDescription>{page.data.description}</DocsDescription>
30+
<DocsBody>
31+
<MDXContent
32+
components={getMDXComponents({
33+
// this allows you to link to other pages with relative file paths
34+
a: createRelativeLinkWithFilenameOnly(source, page),
35+
})}
36+
/>
37+
</DocsBody>
38+
</DocsPage>
39+
);
40+
}
41+
42+
export async function generateStaticParams() {
43+
return source.generateParams();
44+
}
45+
46+
export async function generateMetadata(props: {
47+
params: Promise<{ slug?: string[] }>;
48+
}) {
49+
const params = await props.params;
50+
const page = source.getPage(params.slug);
51+
if (!page) notFound();
52+
53+
return {
54+
title: page.data.title,
55+
description: page.data.description,
56+
};
57+
}
58+
59+
function createRelativeLinkWithFilenameOnly(
60+
source: LoaderOutput<LoaderConfig>,
61+
page: Page,
62+
): FC<ComponentProps<'a'>> {
63+
return async function RelativeLink({href, ...props}) {
64+
const relativeLink = createRelativeLink(source, page)
65+
// support filename-only links
66+
if (href && (!href.startsWith('http') && href.endsWith('.md'))) {
67+
return relativeLink({href: `./${href}`, ...props});
68+
}
69+
return relativeLink({href, ...props});
70+
};
71+
}

app/api/search/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {source} from '@/lib/source';
2+
import {createFromSource} from 'fumadocs-core/search/server';
3+
4+
export const revalidate = false;
5+
6+
export const {staticGET: GET} = createFromSource(source);

0 commit comments

Comments
 (0)