import MarkdownRenderer from "@/src/components/general/markdown-renderer";
import Breadcrumbs from "@/src/components/lib/elements/Breadcrumbs";
import Divider from "@/src/components/lib/layout/Divider";
import H1 from "@/src/components/lib/layout/H1";
import Row from "@/src/components/lib/layout/Row";
import Section from "@/src/components/lib/layout/Section";
import Span from "@/src/components/lib/layout/Span";
import Stack from "@/src/components/lib/layout/Stack";
import { AppContext } from "@/src/pages/__root";
import { Clock } from "lucide-react";
import React from "react";

export default function Main() {
    const { pageProps, url } = React.useContext(AppContext);
    const { blogPost } = pageProps || {};

    return (
        <Section>
            <Stack className="w-full max-w-full xl:max-w-[800px] overflow-auto">
                {/* <Divider dashed className="border-[2px] my-6" /> */}
                <Stack className="gap-1">
                    <H1 className="leading-snug mb-1">{blogPost?.title}</H1>
                    <Span>{blogPost?.excerpt}</Span>
                    <Stack className="gap-2 mt-2">
                        <Breadcrumbs
                            divider={<span className="opacity-40">/</span>}
                            linkProps={{
                                className: "!text-white border-none",
                            }}
                            currentLinkProps={{
                                className: " opacity-40 pointer-events-none",
                            }}
                            pageUrl={`${url?.pathname}`}
                            backButton
                        />
                        <Row className="mt-1">
                            <Clock
                                size={13}
                                opacity={0.5}
                                className="-mt-[1px]"
                            />
                            <Span size="smaller" variant="faded">
                                {blogPost?.date_created?.substring(0, 24)}
                            </Span>
                        </Row>
                    </Stack>
                </Stack>
                <Divider dashed className="border-[2px] my-6" />
                <MarkdownRenderer content={blogPost?.body || ""} />
                {/* <MarkdownRenderer content={blogPost?.body || "No Content"} /> */}
            </Stack>
        </Section>
    );
}
