Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit e595551

Browse files
author
Greg Rickaby
authored
Merge pull request #22 from WebDevStudios/feature/custom-fields
Custom Fields
2 parents ec97576 + 2b9cc1d commit e595551

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

components/custom-fields.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import PropTypes from 'prop-types'
2+
3+
export default function CustomFields({customFields}) {
4+
return (
5+
<div className="max-w-2xl mx-auto">
6+
<h3 className="mt-8 text-lg font-bold">What I&apos;m Into</h3>
7+
{customFields.book && <p className="mt-3">Book: {customFields.book}</p>}
8+
{customFields.music && (
9+
<p className="mt-3">Music: {customFields.music}</p>
10+
)}
11+
{customFields.television && (
12+
<p className="mt-3">Television: {customFields.television}</p>
13+
)}
14+
</div>
15+
)
16+
}
17+
18+
CustomFields.propTypes = {
19+
customFields: PropTypes.object
20+
}

lib/api.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ export async function getPostAndMorePosts(slug, preview, previewData) {
149149
}
150150
}
151151
}
152+
acf_whatiminto {
153+
book
154+
music
155+
television
156+
}
152157
}
153158
query PostBySlug($id: ID!, $idType: PostIdType!) {
154159
post(id: $id, idType: $idType) {
@@ -169,6 +174,11 @@ export async function getPostAndMorePosts(slug, preview, previewData) {
169174
...AuthorFields
170175
}
171176
}
177+
acf_whatiminto {
178+
book
179+
music
180+
television
181+
}
172182
}
173183
}
174184
}

pages/posts/[slug].js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import PostTitle from '@/components/post-title'
1313
import Head from 'next/head'
1414
import {CMS_NAME} from '@/lib/config'
1515
import Tags from '@/components/tags'
16+
import CustomFields from '@/components/custom-fields'
1617

1718
export default function Post({post, posts, preview}) {
1819
const router = useRouter()
@@ -48,6 +49,9 @@ export default function Post({post, posts, preview}) {
4849
categories={post.categories}
4950
/>
5051
<PostBody content={post.content} />
52+
<div>
53+
<CustomFields customFields={post.acf_whatiminto} />
54+
</div>
5155
<footer>
5256
{post.tags.edges.length > 0 && <Tags tags={post.tags} />}
5357
</footer>

0 commit comments

Comments
 (0)