Skip to content

Instantly share code, notes, and snippets.

@rojcyk
Last active July 16, 2021 14:14
Show Gist options
  • Save rojcyk/0dee8f2f6d338809fee232775dbcd565 to your computer and use it in GitHub Desktop.
Save rojcyk/0dee8f2f6d338809fee232775dbcd565 to your computer and use it in GitHub Desktop.
Blog outpout styling
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>
)
}
/*
* 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