Created
December 4, 2018 13:43
-
-
Save patricoferris/6c6d6579f5fbdc40fdcb820568247a29 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 Layout from '../components/layout'; | |
import { graphql } from 'gatsby'; | |
// Functional component | |
const notes = (props) => { | |
const notesMarkdown = props.data.markdownRemark; | |
const { title } = notesMarkdown.frontmatter; | |
// Setting the inner HTML to the HTML provided by MarkdownRemark | |
return ( | |
<Layout> | |
<h1>{title}</h1> | |
<div dangerouslySetInnerHTML={{__html: notesMarkdown.html}}></div> | |
</Layout> | |
); | |
} | |
export default notes; | |
// The query for getting the correct markdown-remark data (matching on the slugs) | |
export const query = graphql` | |
query NotesQuery($slug: String!) { | |
markdownRemark(fields: { slug: {eq: $slug } }) { | |
html | |
frontmatter { | |
title | |
description | |
} | |
} | |
} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment