-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.tsx
61 lines (58 loc) · 1.4 KB
/
index.tsx
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
import * as React from "react"
import { graphql } from "gatsby"
import Layout from "../components/layout"
import * as sections from "../components/sections"
import Fallback from "../components/fallback"
import SEOHead from "../components/head"
interface HomepageProps {
data: {
homepage: {
id: string
title: string
description: string
image: { id: string; url: string }
blocks: sections.HomepageBlock[]
}
}
}
export default function Homepage(props: HomepageProps) {
const { homepage } = props.data
return (
<Layout>
{homepage.blocks.map((block) => {
const { id, blocktype, ...componentProps } = block
const Component = sections[blocktype] || Fallback
return <Component key={id} {...(componentProps as any)} />
})}
</Layout>
)
}
export const Head = (props: HomepageProps) => {
const { homepage } = props.data
return <SEOHead {...homepage} />
}
export const query = graphql`
{
homepage {
id
title
description
image {
id
url
}
blocks: content {
id
blocktype
...HomepageHeroContent
...HomepageFeatureListContent
...HomepageCtaContent
...HomepageLogoListContent
...HomepageTestimonialListContent
...HomepageBenefitListContent
...HomepageStatListContent
...HomepageProductListContent
}
}
}
`