forked from SLoh4137/umcp-tase
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEventPageTemplate.tsx
executable file
·78 lines (67 loc) · 2.21 KB
/
EventPageTemplate.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from "react"
import { graphql, PageProps } from "gatsby"
import {
Container,
Theme,
createStyles,
withStyles,
WithStyles,
} from "@material-ui/core"
import { IndividualEventPageQuery } from "graphql-types"
import ParallaxBackground from "components/PageLayout/ParallaxBackground"
import PageContent from "components/PageLayout/PageContent"
import MarkdownContent from "components/General/MarkdownContent"
import Section from "components/PageLayout/Section"
const styles = (theme: Theme) => createStyles({})
// Note this has to be synchronized with gatsby-node in createPage
type PageContext = {
slug: string
cover: string
nextTitle: string
nextSlug: string
prevTitle: string
prevSlug: string
}
type Props = {
data: IndividualEventPageQuery
pageContext: PageContext
} & PageProps &
WithStyles<typeof styles>
function EventPageTemplate(props: Props) {
const { data, pageContext, location, classes } = props
// pageContext dictates the relationship between this page and others
// For example, a component could display the next event's title and a link to it with the given parameters
// location could be used to show the current pathname
if (!data.markdownRemark?.frontmatter?.title)
throw new Error("Title not provided")
if (!data.file) throw new Error("Image doesn't exist")
if (!data.markdownRemark.html) throw new Error("No description")
return (
<>
<ParallaxBackground image={data.file} imageHeight="60vh" />
<PageContent>
<Section title={data.markdownRemark.frontmatter.title}>
<MarkdownContent content={data.markdownRemark.html} />
</Section>
</PageContent>
</>
)
}
export const query = graphql`
query IndividualEventPage($slug: String, $imgsrc: String) {
markdownRemark(fields: { slug: { eq: $slug } }) {
html
id
frontmatter {
title
tags
date
link
}
}
file(relativePath: { eq: $imgsrc }) {
...BackgroundImage
}
}
`
export default withStyles(styles)(EventPageTemplate)