Last active
September 23, 2019 07:33
-
-
Save abedzantout/a9f1f5a57b434d2c05e97632e9aeaca3 to your computer and use it in GitHub Desktop.
Post.tsx without Meta Tags
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 { NextPage } from 'next'; | |
| import React from 'react'; | |
| import ReactMarkdown from 'react-markdown'; | |
| import './styles.css'; | |
| import { ContentfulService } from '../../core/contentful'; | |
| import Layout from '../../shared/components/layout/layout.component'; | |
| import { BlogPost } from '../../interfaces/post'; | |
| type Props = { | |
| article: BlogPost; | |
| }; | |
| const PostPage: NextPage = (props: Props) => { | |
| return ( | |
| <Layout> | |
| <div className="post-container" id="post-container"> | |
| <div className="post-header"> | |
| <h1>{props.article.title}</h1> | |
| <div className="author"> | |
| <p>Written by {props.article.author.name}</p> | |
| </div> | |
| </div> | |
| <ReactMarkdown className="markdown" source={props.article.body}/> | |
| </div> | |
| </Layout> | |
| ); | |
| }; | |
| PostPage.getInitialProps = async ({query}) => { | |
| // define contentful service instance | |
| const contentfulService = new ContentfulService(); | |
| const {post} = query; | |
| const article = await contentfulService.getPostBySlug(post); | |
| return {article}; | |
| }; | |
| export default PostPage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment