forked from rage/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfoPageTemplate.js
More file actions
61 lines (54 loc) · 1.53 KB
/
Copy pathInfoPageTemplate.js
File metadata and controls
61 lines (54 loc) · 1.53 KB
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 React, { Fragment } from "react"
import { graphql } from "gatsby"
import styled from "styled-components"
import rehypeReact from "rehype-react"
import { Helmet } from "react-helmet"
import Layout from "./Layout"
import getNamedPartials from "../partials"
import "./remark.css"
import { LoginStateContextProvider } from "../contexes/LoginStateContext"
import Container from "../components/Container"
import Banner from "../components/Banner"
const ContentWrapper = styled.article``
export default class InfoPageTemplate extends React.Component {
render() {
const { data } = this.props
const { frontmatter, htmlAst } = data.page
const partials = getNamedPartials()
const renderAst = new rehypeReact({
createElement: React.createElement,
components: partials,
}).Compiler
return (
<Fragment>
<Helmet title={frontmatter.title} />
<LoginStateContextProvider>
<Layout>
<Fragment>
{frontmatter.banner && <Banner />}
<Container>
<ContentWrapper>
<h1>{frontmatter.title}</h1>
{renderAst(htmlAst)}
</ContentWrapper>
</Container>
</Fragment>
</Layout>
</LoginStateContextProvider>
</Fragment>
)
}
}
export const pageQuery = graphql`
query($path: String!) {
page: markdownRemark(frontmatter: { path: { eq: $path } }) {
htmlAst
html
frontmatter {
path
title
banner
}
}
}
`