Skip to content

Commit

Permalink
feat: integrate GitHub last edit functionality and enhance page rende…
Browse files Browse the repository at this point in the history
…ring options
  • Loading branch information
joao-vasconcelos committed Jan 2, 2025
1 parent ec98263 commit 770126a
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions app/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* * */

import { openapi, source } from '@/lib/source';
import { getGithubLastEdit } from 'fumadocs-core/server';
import { createTypeTable } from 'fumadocs-typescript/ui';
import defaultMdxComponents from 'fumadocs-ui/mdx';
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/page';
Expand Down Expand Up @@ -28,16 +29,50 @@ export async function generateStaticParams() {
/* * */

export default async function Page(props: { params: Promise<{ slug?: string[] }> }) {
//

//
// A. Setup variables

const params = await props.params;

const page = source.getPage(params.slug);
if (!page) notFound();

const { AutoTypeTable } = createTypeTable();

//
// B. Setup options

const editOnGithubOptions = {
owner: 'carrismetropolitana',
path: `content/${page.file.path}`,
repo: 'docs',
sha: 'production',
};

const lastUpdateOptions = await getGithubLastEdit({
owner: 'carrismetropolitana',
path: `content/${page.file.path}`,
repo: 'docs',
});

const MDX = page.data.body;

const { AutoTypeTable } = createTypeTable();
//
// C. Render components

return (
<DocsPage full={page.data.full} toc={page.data.toc}>
<DocsPage
editOnGithub={editOnGithubOptions}
lastUpdate={new Date(lastUpdateOptions ?? 0)}
toc={page.data.toc}
tableOfContent={{
enabled: true,
style: 'clerk',
}}
full
>
<DocsTitle>{page.data.title}</DocsTitle>
<DocsDescription>{page.data.description}</DocsDescription>
<DocsBody>
Expand Down

0 comments on commit 770126a

Please sign in to comment.