/
{contentfulPosts.url}.js
93 lines (88 loc) · 2.11 KB
/
{contentfulPosts.url}.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React from 'react'
import { graphql } from 'gatsby'
import { GatsbyImage, getImage } from 'gatsby-plugin-image'
import Seo from '../components/seo'
import ContentfulRichTech from '../components/contentful-rich-text'
const Post = ({
data: {
contentfulPosts: {
featuredImage,
url,
seoTitle,
seoDescription: { seoDescription },
postTitle,
author,
createdAt,
richText,
},
},
}) => {
return (
<>
<Seo
customTitle={seoTitle}
customDescription={seoDescription}
customUrl={url}
customImage={featuredImage}
/>
<article className="max-w-screen-lg mx-auto">
<div className="grid gap-x-8 gap-y-10 grid-cols-1 lg:grid-cols-blog">
<div>
{featuredImage ? (
<GatsbyImage
image={getImage(featuredImage)}
alt={postTitle}
className="mb-6"
/>
) : null}
<h1 className="text-4xl sm:text-5xl text-left font-black text-gray-700 leading-tight mb-6">
{postTitle}
</h1>
</div>
<div>
<div className="grid gap-1 text-sm mb-10">
<p className="text-brand-default font-bold text-base">{author}</p>
<p className="text-gray-600">
{new Date(createdAt).toLocaleDateString()}
</p>
</div>
<hr />
</div>
<section>
<ContentfulRichTech richText={richText} />
</section>
</div>
</article>
</>
)
}
export default Post
export const query = graphql`
query ($id: String) {
contentfulPosts(id: { eq: $id }) {
featuredImage {
gatsbyImageData
}
url
seoTitle
seoDescription {
seoDescription
}
postTitle
author
createdAt
richText {
raw
references {
... on ContentfulAsset {
contentful_id
title
description
gatsbyImageData(width: 1000)
__typename
}
}
}
}
}
`