Last active
January 5, 2019 14:24
-
-
Save brookslyrette/993983cf1da2ce85a84ec7bdb5455aeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import Gist from 'react-gist' | |
import Markdown from 'markdown-to-jsx' | |
import Layout from '../components/layout' | |
import SEO from '../components/seo' | |
const ScriptHandler = (props) => { | |
// if the script is a gist override it with our react component. | |
if (props.src && props.src.includes('gist.github.com')) { | |
return <Gist id={props.src.split('/')[4].split('.')[0]}/> | |
} | |
return null | |
} | |
export default ({ pageContext }) => { | |
const { post } = pageContext | |
return ( | |
<Layout> | |
<SEO title={post.title} keywords={[`gatsby`, `application`, `react`]} /> | |
<h1> {post.title} </h1> | |
<Markdown options={{ | |
overrides: { | |
script: { | |
component: ScriptHandler | |
}, | |
}, | |
}} | |
> | |
{post.markdown} | |
</Markdown> | |
</Layout> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment