Permalink
Browse files

Wireup WordPress content

  • Loading branch information...
booyaa committed Jan 1, 2019
1 parent 13a036a commit 50156723a4b21f08baeece9a5f7cd3936e384ee8
Showing with 33 additions and 9 deletions.
  1. +33 −9 src/templates/post.js
@@ -1,10 +1,34 @@
import React from 'react';
import Layout from '../components/layout';
import React from 'react'
import { graphql } from 'gatsby'
import Layout from '../components/layout'

export default () => {
return (
<Layout>
<div>Hello blog post</div>
</Layout>
)
}
export default ({ data }) => {
const post = data.wordpressPost
return (
<Layout>
<div>
<h1 dangerouslySetInnerHTML={{ __html: post.title }} />
<h3>
date: {post.date} tags: {extractTags(post)}{' '}
</h3>
<div dangerouslySetInnerHTML={{ __html: post.content }} />
</div>
</Layout>
)
}

const extractTags = post =>
post.tags ? post.tags.map(x => x.name).join(', ') : 'none'

export const pageQuery = graphql`
query($id: String!) {
wordpressPost(id: { eq: $id }) {
title
tags {
name
}
date(formatString: "Do MMMM YYYY")
content
}
}
`

0 comments on commit 5015672

Please sign in to comment.