import React from "react";
import Image from "next/image";

function BlogContent({ post }: { post: any }) {
  return (
    <>
      <h1 className="text-3xl text-black dark:text-slate-200">{post.title}</h1>
      <div className="flex items-center gap-2">
        {/* Not sure if name is required */}
        <p className="text-black dark:text-slate-200">{post.author ?? ""}</p>
        <span className="text-black dark:text-slate-200">|</span>
        <p className="text-black dark:text-slate-200">
          {new Date(post.date).toLocaleDateString()}
        </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.imageUrl}
            alt="post-image"
            width={0}
            height={0}
            sizes="100%"
            style={{
              display: "block",
              width: "100%",
              height: "100%",
              objectFit: "cover",
            }}
          />
        </div>
        <div dangerouslySetInnerHTML={{ __html: post.content }}></div>
      </article>
    </>
  );
}

export default BlogContent;
