import React, { Component } from 'react'
import Helmet from 'react-helmet'
import Prism from 'prismjs'

require('prismjs/themes/prism-solarizedlight.css')

import PageTransition from 'gatsby-plugin-page-transitions'

import favicon32 from '../images/favicon32.png'

class PostDefault extends Component {
  componentDidMount() {
    Prism.highlightAll()
  }
  render() {
    const { data } = this.props
    return (
      <PageTransition>
        <Helmet
          title={`${data.wordpressPost.title} - Saburly.com`}
          meta={[
            { name: 'description', content: 'We code & design great software' },
            {
              name: 'keywords',
              content:
                'software, design, coding, programming, code, consulting',
            },
          ]}
          link={[
            { rel: 'shortcut icon', type: 'image/png', href: `${favicon32}` },
          ]}
        />
        <main className="container mx-auto p-4 max-w-lg sm:p-10">
          <h1>{data.wordpressPost.title}</h1>
          <div
            className="leading-normal blog-post"
            dangerouslySetInnerHTML={{
              __html: data.wordpressPost.content,
            }}
          />
        </main>
      </PageTransition>
    )
  }
}

export const query = graphql`
  query PostDefaultQuery($slug: String!) {
    wordpressPost(slug: { eq: $slug }) {
      title
      slug
      content
    }
  }
`

export default PostDefault
