1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-10 11:35:10 +02:00
blog/src/templates/post.jsx

72 lines
1.6 KiB
React
Raw Normal View History

2018-07-17 23:33:55 +02:00
import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import { graphql } from 'gatsby'
2018-07-18 00:24:11 +02:00
import Layout from '../components/Layout'
import Image from '../components/atoms/Image'
2018-07-19 02:22:01 +02:00
import PostMeta from '../components/molecules/PostMeta'
2018-07-18 23:04:31 +02:00
import styles from './Post.module.scss'
2018-07-17 23:33:55 +02:00
const Post = ({ data }) => {
const { markdownRemark: post } = data
2018-07-19 02:22:01 +02:00
const { contentYaml: meta } = data
2018-07-17 23:33:55 +02:00
const { title, image } = post.frontmatter
return (
2018-07-18 00:24:11 +02:00
<Layout location={location}>
2018-07-17 23:33:55 +02:00
<Helmet title={title} />
2018-07-18 23:04:31 +02:00
<article className={styles.hentry}>
<h1 className={styles.hentry__title}>{title}</h1>
{image && (
<figure className={styles.hentry__teaser}>
<Image fluid={image.childImageSharp.fluid} alt={title} />
</figure>
)}
2018-07-17 23:33:55 +02:00
<div
2018-07-18 23:04:31 +02:00
className={styles.hentry__content}
2018-07-17 23:33:55 +02:00
dangerouslySetInnerHTML={{ __html: post.html }}
/>
2018-07-19 02:22:01 +02:00
<PostMeta post={post} meta={meta} />
2018-07-18 00:24:11 +02:00
</article>
</Layout>
2018-07-17 23:33:55 +02:00
)
}
Post.propTypes = {
data: PropTypes.object.isRequired
}
export default Post
export const pageQuery = graphql`
query BlogPostByPath($slug: String!) {
markdownRemark(fields: { slug: { eq: $slug } }) {
html
frontmatter {
title
image {
childImageSharp {
...ImageFluid
}
}
2018-07-19 02:22:01 +02:00
author
updated
category
tags
2018-07-17 23:33:55 +02:00
}
fields {
slug
date(formatString: "MMMM DD, YYYY")
}
}
2018-07-19 02:22:01 +02:00
contentYaml {
author {
uri
}
}
2018-07-17 23:33:55 +02:00
}
`