Skip to content

Commit

Permalink
improve docs landing
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremybosma committed Jul 24, 2024
1 parent b1e6980 commit e519202
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
56 changes: 44 additions & 12 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
import Link from 'next/link';
import { pageTree } from './source';
import { getPage, getPages } from '@/app/source';
import type { Metadata } from 'next';
import { DocsPage, DocsBody } from 'fumadocs-ui/page';
import { notFound } from 'next/navigation';
import { DocsLayout } from 'fumadocs-ui/layout';

export default async function Page({
params,
}: {
params: { slug?: "index"[] };
}) {
const page = getPage(params.slug);

if (page == null) {
notFound();
}

const MDX = page.data.exports.default;

export default function HomePage() {
return (
<main className="flex h-screen flex-col justify-center text-center">
<h1 className="mb-4 text-2xl font-bold">Hello World</h1>
<p className="text-muted-foreground">
You can open{' '}
<Link href="/docs" className="text-foreground font-semibold underline">
/docs
</Link>{' '}
and see the documentation.
</p>
</main>
<DocsLayout tree={pageTree}>
<DocsPage toc={page.data.exports.toc}>
<DocsBody>
<h1>{page.data.title}</h1>
<MDX />
</DocsBody>
</DocsPage>
</DocsLayout>
);
}

export async function generateStaticParams() {
return getPages().map((page) => ({
slug: page.slugs,
}));
}

export function generateMetadata({ params }: { params: { slug?: string[] } }) {
const page = getPage(params.slug);

if (page == null) notFound();

return {
title: page.data.title,
description: page.data.description,
} satisfies Metadata;
}
9 changes: 0 additions & 9 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ const config = {
unoptimized: true,
},
reactStrictMode: true,
async redirects() {
return [
{
source: '/',
destination: '/docs',
permanent: true,
},
];
}
};

export default withMDX(config);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"autoprefixer": "^10.4.19",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4"
}
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

0 comments on commit e519202

Please sign in to comment.