Last active
August 3, 2020 07:24
-
-
Save timsuchanek/1b1417dcbf0c129f81cdbf651f74f71f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Layout from '../../components/layout' | |
import { getAllPostIds, getPostData } from '../../lib/posts' | |
import Head from 'next/head' | |
import Date from '../../components/date' | |
import utilStyles from '../../styles/utils.module.css' | |
/** | |
* @param {import('next').InferGetStaticPropsType<typeof getStaticProps> } props | |
*/ | |
export default function Post(props) { | |
const { postData } = props | |
return ( | |
<Layout> | |
<Head> | |
<title>{postData.title}</title> | |
</Head> | |
<article> | |
<h1 className={utilStyles.headingXl}>{postData.title}</h1> | |
<div className={utilStyles.lightText}> | |
<Date dateString={postData.date} /> | |
</div> | |
<div dangerouslySetInnerHTML={{ __html: postData.contentHtml }} /> | |
</article> | |
</Layout> | |
) | |
} | |
export async function getStaticPaths() { | |
const paths = getAllPostIds() | |
return { | |
paths, | |
fallback: false, | |
} | |
} | |
export async function getStaticProps({ params }) { | |
const postData = await getPostData(params.id) | |
return { | |
props: { | |
postData, | |
}, | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Layout from '../../components/layout' | |
import { getAllPostIds, getPostData } from '../../lib/posts' | |
import Head from 'next/head' | |
import Date from '../../components/date' | |
import utilStyles from '../../styles/utils.module.css' | |
import { InferGetStaticPropsType } from 'next' | |
export default function Post(props: InferGetStaticPropsType<typeof getStaticProps>) { | |
const { postData } = props | |
return ( | |
<Layout> | |
<Head> | |
<title>{postData.title}</title> | |
</Head> | |
<article> | |
<h1 className={utilStyles.headingXl}>{postData.title}</h1> | |
<div className={utilStyles.lightText}> | |
<Date dateString={postData.date} /> | |
</div> | |
<div dangerouslySetInnerHTML={{ __html: postData.contentHtml }} /> | |
</article> | |
</Layout> | |
) | |
} | |
export async function getStaticPaths() { | |
const paths = getAllPostIds() | |
return { | |
paths, | |
fallback: false, | |
} | |
} | |
export async function getStaticProps({ params }) { | |
const postData = await getPostData(params.id) | |
return { | |
props: { | |
postData, | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment