import Date from "components/Date"
import { getAllPostIDs, getPostData  } from "utils/shared/posts"

export default function Blog({data}) {
    return (
        <>
        {data.slug}
        <br />
        {data.title}
        <br />
        <Date dateString={data.date} />
        <br />
        <div className="content" dangerouslySetInnerHTML={{__html: data.content}} />
        </>
    )
}

export async function getStaticPaths() {
    const paths = getAllPostIDs()
    // console.log(paths)
    return {
        paths,
        fallback: false,
      };
}

export async function getStaticProps({ params }) {
    const data = await getPostData(params.slug);
    // console.log(data)
    return {
      props: {
        data,
      },
    };
  }