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

Commit 55a1f05

Browse files
committed
Add cards to blog and team pages
1 parent 3be82ef commit 55a1f05

File tree

2 files changed

+54
-52
lines changed

2 files changed

+54
-52
lines changed

pages/blog/[[...slug]].js

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
import getArchivePosts from '@/api/frontend/wp/archive/getArchivePosts'
2+
import postComment from '@/api/frontend/wp/comments/postComment'
13
import getPostTypeStaticPaths from '@/api/wordpress/_global/getPostTypeStaticPaths'
24
import getPostTypeStaticProps from '@/api/wordpress/_global/getPostTypeStaticProps'
5+
import Button from '@/components/atoms/Button'
6+
import Text from '@/components/atoms/Inputs/Text'
37
import Layout from '@/components/common/Layout'
4-
import Link from 'next/link'
5-
import getArchivePosts from '@/api/frontend/wp/archive/getArchivePosts'
6-
import postComment from '@/api/frontend/wp/comments/postComment'
7-
import getPagePropTypes from '@/functions/getPagePropTypes'
88
import Blocks from '@/components/molecules/Blocks'
9+
import Card from '@/components/molecules/Card'
910
import Form from '@/components/molecules/Form'
10-
import Text from '@/components/atoms/Inputs/Text'
11+
import getPagePropTypes from '@/functions/getPagePropTypes'
1112
import * as Yup from 'yup'
1213

1314
// Define route post type.
@@ -38,28 +39,28 @@ export default function BlogPost({post, archive, posts, pagination}) {
3839
if (archive) {
3940
return (
4041
<Layout seo={{...post?.seo}}>
41-
<div className="container py-20">
42-
<section>
43-
{!posts || !posts.length ? (
44-
<p>No posts found.</p>
45-
) : (
46-
posts.map((post, index) => (
47-
<article key={index}>
48-
<Link href={post?.uri}>
49-
<a>
50-
<h1 dangerouslySetInnerHTML={{__html: post?.title}} />
51-
</a>
52-
</Link>
53-
<div dangerouslySetInnerHTML={{__html: post?.excerpt}} />
54-
</article>
55-
))
56-
)}
57-
{/* TODO: replace this with a component. */}
58-
<button onClick={loadPosts} disabled={!pagination.hasNextPage}>
59-
Load more
60-
</button>
61-
</section>
62-
</div>
42+
<section className="container py-20">
43+
{!posts || !posts.length ? (
44+
<p>No posts found.</p>
45+
) : (
46+
<div className="w-1/3 grid grid-cols-1 gap-12">
47+
{posts.map((post, index) => (
48+
<Card
49+
key={index}
50+
title={post?.title}
51+
url={post?.uri}
52+
body={post?.excerpt}
53+
/>
54+
))}
55+
</div>
56+
)}
57+
<Button
58+
onClick={() => loadPosts}
59+
text="Load More"
60+
type="secondary"
61+
disabled={!pagination.hasNextPage}
62+
/>
63+
</section>
6364
</Layout>
6465
)
6566
}

pages/team/[[...slug]].js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import getArchivePosts from '@/api/frontend/wp/archive/getArchivePosts'
12
import getPostTypeStaticPaths from '@/api/wordpress/_global/getPostTypeStaticPaths'
23
import getPostTypeStaticProps from '@/api/wordpress/_global/getPostTypeStaticProps'
4+
import Button from '@/components/atoms/Button'
35
import Layout from '@/components/common/Layout'
4-
import Link from 'next/link'
5-
import getArchivePosts from '@/api/frontend/wp/archive/getArchivePosts'
6-
import getPagePropTypes from '@/functions/getPagePropTypes'
76
import Blocks from '@/components/molecules/Blocks'
7+
import Card from '@/components/molecules/Card'
8+
import getPagePropTypes from '@/functions/getPagePropTypes'
89

910
// Define route post type.
1011
const postType = 'team'
@@ -34,28 +35,28 @@ export default function Team({post, archive, posts, pagination}) {
3435
if (archive) {
3536
return (
3637
<Layout seo={{...post?.seo}}>
37-
<div className="container">
38-
<section>
39-
{!posts || !posts.length ? (
40-
<p>No posts found.</p>
41-
) : (
42-
posts.map((post, index) => (
43-
<article key={index}>
44-
<Link href={post.uri}>
45-
<a>
46-
<h1 dangerouslySetInnerHTML={{__html: post?.title}} />
47-
</a>
48-
</Link>
49-
<div dangerouslySetInnerHTML={{__html: post?.excerpt}} />
50-
</article>
51-
))
52-
)}
53-
{/* TODO: replace this with a component. */}
54-
<button onClick={loadPosts} disabled={!pagination.hasNextPage}>
55-
Load more
56-
</button>
57-
</section>
58-
</div>
38+
<section className="container py-20">
39+
{!posts || !posts.length ? (
40+
<p>No posts found.</p>
41+
) : (
42+
<div className="w-1/3 grid grid-cols-1 gap-12">
43+
{posts.map((post, index) => (
44+
<Card
45+
key={index}
46+
title={post?.title}
47+
url={post?.uri}
48+
body={post?.excerpt}
49+
/>
50+
))}
51+
</div>
52+
)}
53+
<Button
54+
onClick={() => loadPosts}
55+
text="Load More"
56+
type="secondary"
57+
disabled={!pagination.hasNextPage}
58+
/>
59+
</section>
5960
</Layout>
6061
)
6162
}

0 commit comments

Comments
 (0)