Skip to content

Instantly share code, notes, and snippets.

@abedzantout
Last active September 23, 2019 07:33
Show Gist options
  • Save abedzantout/a9f1f5a57b434d2c05e97632e9aeaca3 to your computer and use it in GitHub Desktop.
Save abedzantout/a9f1f5a57b434d2c05e97632e9aeaca3 to your computer and use it in GitHub Desktop.
Post.tsx without Meta Tags
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