mirror of
https://github.com/ershisan99/www.git
synced 2026-01-03 21:02:05 +00:00
add fumadocs
This commit is contained in:
47
src/app/docs/[[...slug]]/page.tsx
Normal file
47
src/app/docs/[[...slug]]/page.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import defaultMdxComponents from 'fumadocs-ui/mdx'
|
||||
import {
|
||||
DocsBody,
|
||||
DocsDescription,
|
||||
DocsPage,
|
||||
DocsTitle,
|
||||
} from 'fumadocs-ui/page'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { metadataImage } from '../../../../lib/metadata'
|
||||
import { source } from '../../../../lib/source'
|
||||
|
||||
export default async function Page(props: {
|
||||
params: Promise<{ slug?: string[] }>
|
||||
}) {
|
||||
const params = await props.params
|
||||
const page = source.getPage(params.slug)
|
||||
if (!page) notFound()
|
||||
|
||||
const MDX = page.data.body
|
||||
|
||||
return (
|
||||
<DocsPage toc={page.data.toc} full={page.data.full}>
|
||||
<DocsTitle>{page.data.title}</DocsTitle>
|
||||
<DocsDescription>{page.data.description}</DocsDescription>
|
||||
<DocsBody>
|
||||
<MDX components={{ ...defaultMdxComponents }} />
|
||||
</DocsBody>
|
||||
</DocsPage>
|
||||
)
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
return source.generateParams()
|
||||
}
|
||||
|
||||
export async function generateMetadata(props: {
|
||||
params: Promise<{ slug?: string[] }>
|
||||
}) {
|
||||
const params = await props.params
|
||||
const page = source.getPage(params.slug)
|
||||
if (!page) notFound()
|
||||
|
||||
return metadataImage.withImage(page.slugs, {
|
||||
title: page.data.title,
|
||||
description: page.data.description,
|
||||
})
|
||||
}
|
||||
13
src/app/docs/layout.tsx
Normal file
13
src/app/docs/layout.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { baseOptions } from '@/app/layout.config'
|
||||
import { DocsLayout } from 'fumadocs-ui/layouts/notebook'
|
||||
import type { ReactNode } from 'react'
|
||||
import { source } from '../../../lib/source'
|
||||
|
||||
export default function Layout({ children }: { children: ReactNode }) {
|
||||
console.log(baseOptions)
|
||||
return (
|
||||
<DocsLayout {...baseOptions} tree={source.pageTree}>
|
||||
{children}
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user