forked from chetanverma16/react-portfolio-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
378cefb
commit 131c20c
Showing
4 changed files
with
71 additions
and
106 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React from "react"; | ||
import { getPostBySlug, getAllPosts } from "../../utils/api"; | ||
import markdownToHtml from "../../utils/markdownToHtml"; | ||
import Header from "../../components/Header"; | ||
|
||
const BlogPost = ({ post }) => { | ||
console.log(post); | ||
return ( | ||
<div className="container mx-auto mt-10"> | ||
<Header isBlog={true} /> | ||
<div className="mt-10 flex flex-col"> | ||
<img | ||
className="w-full h-96 rounded-lg shadow-lg object-cover" | ||
src={post.image}></img> | ||
<h1 className="mt-10 text-4xl mob:text-2xl laptop:text-6xl text-bold"> | ||
{post.title} | ||
</h1> | ||
<h2 className="mt-2 text-xl max-w-4xl text-darkgray opacity-50"> | ||
{post.tagline} | ||
</h2> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export async function getStaticProps({ params }) { | ||
const post = getPostBySlug(params.slug, [ | ||
"date", | ||
"slug", | ||
"title", | ||
"tagline", | ||
"preview", | ||
"image", | ||
"keywords", | ||
"author", | ||
"readingtime", | ||
"content", | ||
]); | ||
const content = await markdownToHtml(post.content || ""); | ||
|
||
return { | ||
props: { | ||
post: { | ||
...post, | ||
content, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
export async function getStaticPaths() { | ||
const posts = getAllPosts(["slug"]); | ||
|
||
return { | ||
paths: posts.map((post) => { | ||
return { | ||
params: { | ||
slug: post.slug, | ||
}, | ||
}; | ||
}), | ||
fallback: false, | ||
}; | ||
} | ||
export default BlogPost; |
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