File size: 1,081 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import Header from "./header";
import PostHeader from "./post-header";
import PostBody from "./post-body";
import SectionSeparator from "./section-separator";
import Head from "next/head";
import { CMS_NAME } from "../lib/constants";

export default function PostDetails({ post }) {
  return (
    <>
      <Header />
      <article>
        <Head>
          <title>
            {`${post.title} | Next.js Blog Example with ${CMS_NAME}`}
          </title>
          <meta property="og:image" content={post.ogImage.url} />
        </Head>
        <PostHeader
          title={post.title}
          coverImage={post.coverImage}
          date={post.date}
          author={post.author}
        />
        <PostBody content={post.content} />
      </article>
      <SectionSeparator />
    </>
  );
}

// The data returned here will be send as `props` to the component
PostDetails.getCustomInitialProps = async function ({ client, pageInSitemap }) {
  const contentID = pageInSitemap.contentID;
  const post = await client.getPostDetails({ contentID });

  return {
    post,
  };
};