mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-11 09:51:47 +00:00
32 lines
564 B
JavaScript
32 lines
564 B
JavaScript
import Layout from '../../components/layout';
|
|
import { getAllPostIds, getPostData } from '../../lib/posts';
|
|
|
|
export default function Post({ postData }) {
|
|
return (
|
|
<Layout>
|
|
{postData.title}
|
|
<br />
|
|
{postData.id}
|
|
<br />
|
|
{postData.date}
|
|
</Layout>
|
|
);
|
|
}
|
|
|
|
export async function getStaticPaths() {
|
|
const paths = getAllPostIds();
|
|
return {
|
|
paths,
|
|
fallback: false,
|
|
};
|
|
}
|
|
|
|
export async function getStaticProps({ params }) {
|
|
const postData = getPostData(params.id);
|
|
return {
|
|
props: {
|
|
postData,
|
|
},
|
|
};
|
|
}
|