Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created February 27, 2022 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunosabot/4653bf5059006b804ef3da778c04de51 to your computer and use it in GitHub Desktop.
Save brunosabot/4653bf5059006b804ef3da778c04de51 to your computer and use it in GitHub Desktop.
import { GetStaticProps } from "next";
import loadGreyMatterPost from "../lib/loadGreyMatterPost";
import transformGreyMatterToMDX from "../lib/transformGreyMatterToMDX";
export const getStaticProps: GetStaticProps = async ({ params }) => {
try {
const [post] = loadGreyMatterPost(params);
const mdxSource = transformGreyMatterToMDX(postt);
return {
props: {
source: mdxSource,
post: {
creator: post.data.creator,
date: post.data.date.toString(),
lang: post.data.lang,
path: post.data.path,
title: post.data.title,
},
},
};
} catch (e) {
return { notFound: true };
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment