tailwind-nextjs-blog/pages/about.tsx

32 lines
959 B
TypeScript
Raw Normal View History

2022-10-17 23:37:01 +08:00
import { MDXLayoutRenderer } from '@/components/MDXComponents';
import { getFileBySlug } from '@/lib/mdx';
import { GetStaticProps, InferGetStaticPropsType } from 'next';
import { AuthorFrontMatter } from 'types/AuthorFrontMatter';
2022-10-17 23:37:01 +08:00
const DEFAULT_LAYOUT = 'AuthorLayout';
// @ts-ignore
export const getStaticProps: GetStaticProps<{
2022-10-17 23:37:01 +08:00
authorDetails: { mdxSource: string; frontMatter: AuthorFrontMatter };
}> = async () => {
2022-10-17 23:37:01 +08:00
const authorDetails = await getFileBySlug<AuthorFrontMatter>('authors', [
'default',
]);
const { mdxSource, frontMatter } = authorDetails;
return { props: { authorDetails: { mdxSource, frontMatter } } };
};
2022-10-17 23:37:01 +08:00
export default function About({
authorDetails,
}: InferGetStaticPropsType<typeof getStaticProps>) {
const { mdxSource, frontMatter } = authorDetails;
return (
<MDXLayoutRenderer
layout={frontMatter.layout || DEFAULT_LAYOUT}
mdxSource={mdxSource}
frontMatter={frontMatter}
/>
2022-10-17 23:37:01 +08:00
);
}