Last active
July 16, 2021 14:14
-
-
Save rojcyk/0dee8f2f6d338809fee232775dbcd565 to your computer and use it in GitHub Desktop.
Blog outpout styling
This file contains hidden or 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 RehypeReact from 'rehype-react' | |
/* Importing styled or react components */ | |
import { | |
Headline1, | |
} from './content' | |
/* Mapping the components to the markdown output */ | |
const renderAst = new RehypeReact({ | |
createElement: React.createElement, | |
components: { | |
h1: Headline1 | |
} | |
}).Compiler | |
/* Rendering the blogpost with our mapping */ | |
export default ({ data }) => { | |
const post = data.markdownRemark | |
return ( | |
<div className='blogpost-content'> | |
{renderAst(post.htmlAst)} | |
</div> | |
) | |
} |
This file contains hidden or 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
/* | |
* Define simple styled or react components | |
*/ | |
export const Headline1 = (props) => { | |
return ( | |
<h1 | |
style={{ | |
color: 'red'; | |
}}> | |
{props.children} | |
</h1> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment