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

function BlogContent({ post }: { post: any }) {
  return (
    <div className="bg-base-200 mx-4 lg:mx-0 px-8 py-12 rounded-lg">
      <h1 className="font-heading text-4xl font-bold text-base-content">
        {post.title}
      </h1>
      <div className="flex items-center gap-2">
        {/* Not sure if name is required */}
        {post?.author && (
          <p className="text-base-content">{post.author ?? ""}</p>
        )}
        {post?.author && <span className="text-base-content">|</span>}
        <p className="text-base-content">
          Last modified {new Date(post.updated).toLocaleDateString()}
        </p>
      </div>

      <article className="prose prose-img:rounded-xl max-w-none prose-p:text-base-content prose-a:text-primary prose-h2:text-base-content prose-li:text-base-content prose-strong:text-base-content 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
          className="w-full max-w-[74vw]"
          dangerouslySetInnerHTML={{ __html: post.content }}
        ></div>
      </article>
    </div>
  );
}

export default BlogContent;
