import React from 'react'; import Helmet from 'react-helmet'; import { graphql } from 'gatsby'; import { trimStart, trimEnd } from 'lodash'; import TwitterMeta from '../components/twitter-meta'; import Layout from '../components/layout'; export const BlogPostTemplate = ({ title, author, date, body, html }) => (

{title}

by {author} on {date}

{body ? body :
}
); const BlogPost = ({ data }) => { const { html, frontmatter } = data.markdownRemark; const { author, title, date, description, meta_description, twitter_image } = frontmatter; const { siteUrl } = data.site.siteMetadata; const twitterImageUrl = twitter_image && `${trimEnd(siteUrl, '/')}/${trimStart(twitter_image, '/')}`; const desc = meta_description || description; return ( {title} {desc && } ); }; export default BlogPost; export const pageQuery = graphql` query blogPost($slug: String!) { site { siteMetadata { siteUrl } } markdownRemark(fields: { slug: { eq: $slug } }) { frontmatter { title description # meta_description date(formatString: "MMMM D, YYYY") author twitter_image } html } } `;