import { getSyncComponent } from "@decocms/blocks/cms/client";
import { getBlogConfig } from "../client";
import { CSS } from "../static/css";
import type { BlogPost, Section } from "../types";
export type Props = {
post: BlogPost | null;
};
const iframeStyle: React.CSSProperties = {
width: "100%",
border: "none",
height: "100vh",
};
/**
* Renders one CMS-authored section reference (`{ __resolveType, ...props }`).
*
* The Deno app used `renderSection` from `website/pages/Page.tsx`; here the
* equivalent is the section registry's synchronous component lookup. An
* unregistered `__resolveType` renders nothing rather than throwing — this is a
* preview surface, and a single unknown section should not blank the whole post.
*/
function renderSection(section: Section, index: number) {
const resolveType: string | undefined = section?.__resolveType;
if (!resolveType) return null;
const Component =
getSyncComponent(resolveType) ?? getSyncComponent(resolveType.replace(/\.tsx?$/, ""));
if (!Component) return null;
const { __resolveType: _drop, ...props } = section;
return
{excerpt}
{date ? new Date(`${date}T00:00:00`).toLocaleDateString("en-US", { month: "long", day: "numeric", year: "numeric", }) : ""}
{image && (