Created
January 5, 2019 14:25
-
-
Save brookslyrette/8511627ab8f179d6f0410887e79e2306 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 | |
}, | |
Gist: Gist, | |
}, | |
}} | |
> | |
{post.markdown} | |
</Markdown> | |
</Layout> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment