Quiz-PDF/Frontend/sections/BlogContent.tsx

49 lines
1.5 KiB
TypeScript

import React from "react";
import Image from "next/image";
import matter from "gray-matter";
import Markdown from "markdown-to-jsx";
interface BlogContentProps {
post: matter.GrayMatterFile<string>;
}
function BlogContent({ post }: BlogContentProps) {
return (
<>
<h1 className="text-3xl text-black dark:text-slate-200">
{post.data.title}
</h1>
<div className="flex items-center gap-2">
{/* Not sure if name is required */}
<p className="text-black dark:text-slate-200">
{post.data.author ?? ""}
</p>
<span className="text-black dark:text-slate-200">|</span>
<p className="text-black dark:text-slate-200">{post.data.date}</p>
</div>
<article className="prose prose-img:rounded-xl max-w-none prose-p:text-black dark:prose-p:text-white prose-a:text-primary prose-h2:text-black dark:prose-h2:text-white prose-li:text-black dark:prose-li:text-white prose-strong:text-black dark:prose-strong:text-white prose-blockquote:pr-2 prose-blockquote:font-normal">
<div className="h-full w-full">
<Image
priority
src={post.data.image}
alt="post-image"
width={0}
height={0}
sizes="100%"
style={{
display: "block",
width: "100%",
height: "100%",
objectFit: "cover",
}}
/>
</div>
<Markdown>{post.content}</Markdown>
</article>
</>
);
}
export default BlogContent;