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 { createClient } from 'contentful'; | |
class Post extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
data: null | |
}; |
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
render() { | |
- console.log(this.state.data); | |
- return <p>Post</p>; | |
+ if (!this.state.data) return null; | |
+ | |
+ return ( | |
+ <React.Fragment> | |
+ <h1>{this.state.data.title}</h1> | |
+ {this.state.data.content} | |
+ </React.Fragment> |
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 { createClient } from 'contentful'; | |
+import Helmet from 'react-helmet'; | |
return ( | |
<React.Fragment> | |
+ <Helmet title={this.state.data.title} /> | |
<h1>{this.state.data.title}</h1> | |
{this.state.data.content} | |
</React.Fragment> |
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 React, { createElement } from 'react'; | |
import { createClient } from 'contentful'; | |
import Helmet from 'react-helmet'; | |
+import marksy from 'marksy'; | |
+ | |
+// Markdown helper function | |
+const getMarkup = field => { | |
+ if (!field) return null; | |
+ const compile = marksy({ |
OlderNewer