-
Notifications
You must be signed in to change notification settings - Fork 10
/
article.js
58 lines (53 loc) · 1.21 KB
/
article.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from "react";
import PropTypes from "prop-types";
import { graphql } from "gatsby";
import { Link } from "gatsby"
import { GatsbyImage, getImage} from "gatsby-plugin-image"
import Layout from "../components/layout"
const Article = ({ data }) => {
const post = data.nodeArticle;
const image = getImage(post.relationships.field_image.localFile.childImageSharp.gatsbyImageData)
return (
<Layout>
<h1>{ post.title }</h1>
<Link to="/articles/">
<h4>Back to All Articles</h4>
</Link>
<GatsbyImage image={image} alt={ post.field_image.alt } />
<br/><br/>
<div dangerouslySetInnerHTML={{ __html: post.body.processed }}
/>
</Layout>
);
};
Article.propTypes = {
data: PropTypes.object.isRequired,
}
export const query = graphql `
query($ArticleId: String!) {
nodeArticle(id: {eq: $ArticleId}) {
id
title
body {
processed
}
created
path {
alias
}
field_image {
alt
}
relationships {
field_image {
localFile {
childImageSharp {
gatsbyImageData
}
}
}
}
}
}
`;
export default Article;