forked from izuolan/notionic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewsletter.js
41 lines (35 loc) · 1021 Bytes
/
newsletter.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
import Container from '@/components/Container'
import BlogPost from '@/components/BlogPost'
import NewsletterHero from '@/components/Hero/Newsletter'
import { getAllPosts, getPostBlocks } from '@/lib/notion'
import BLOG from '@/blog.config'
export async function getStaticProps() {
const posts = await getAllPosts({ onlyNewsletter: true })
const heros = await getAllPosts({ onlyHidden: true })
const hero = heros.find((t) => t.slug === 'newsletter')
let blockMap
try {
blockMap = await getPostBlocks(hero.id)
} catch (err) {
console.error(err)
// return { props: { post: null, blockMap: null } }
}
return {
props: {
posts,
blockMap
},
revalidate: 1
}
}
const newsletter = ({ posts, blockMap }) => {
return (
<Container title={BLOG.newsletter} description={BLOG.description}>
<NewsletterHero blockMap={blockMap} />
{posts.map((post) => (
<BlogPost key={post.id} post={post} />
))}
</Container>
)
}
export default newsletter