import { renderToStaticMarkup } from "react-dom/server";
import {
DOC_PAGE_BALANCED_INLINE_OUTLINE_BEFORE_CLASS,
DocumentFrame,
PAGE_SHELL_CLASS,
} from "@/shared/editor/presentation/document-layout";
import { EditorMetricsPresentation } from "@/shared/editor/presentation/metrics";
import { OutlinePresentation } from "@/shared/editor/presentation/outline";
import { SiteOutlineControllerIslandHost } from "@/sites/island-hosts/site-outline-controller";
import { SiteFooter } from "./footer";
import { SiteHeader } from "./header";
import { SiteIconMark } from "./icons";
import {
createSitesApexRenderContext,
createSitesNotFoundRenderContext,
readSitesDocumentAssets,
readSitesHeaderRenderState,
readSitesPageRenderState,
runWithSitesReactRenderContext,
} from "./react-render-context";
import type { ApexDocumentProps, NotFoundDocumentProps, SiteOgImage, SitePageDocumentProps } from "./types";
function isGradient(cover: string): boolean {
return cover.startsWith("linear-gradient(");
}
function PageIcon({ icon }: { icon: string }) {
return (
);
}
function SiteHead({
title,
canonicalUrl,
ogTitle,
ogUrl,
ogType,
ogImage,
description,
includeModulePreloads = true,
}: {
title: string;
canonicalUrl?: string;
ogTitle?: string;
ogUrl?: string;
ogType?: "article" | "website";
ogImage?: SiteOgImage | null;
description?: string | null;
includeModulePreloads?: boolean;
}) {
const assets = readSitesDocumentAssets();
return (
{title}
{canonicalUrl ? : null}
{description ? : null}
{ogType ? : null}
{ogTitle ? : null}
{description ? : null}
{ogUrl ? : null}
{ogImage ? (
<>
>
) : null}
{includeModulePreloads
? assets.modulePreloadHrefs.map((href) => )
: null}
);
}
function SiteDeferredStyles() {
const assets = readSitesDocumentAssets();
return ;
}
export function SitePageDocument({ children }: SitePageDocumentProps) {
const {
page: { title, icon, coverUrl, ogImage, outline, metrics, description, canonicalUrl, site },
} = readSitesPageRenderState();
const coverStyle = coverUrl
? { backgroundImage: isGradient(coverUrl) ? coverUrl : `url(${JSON.stringify(coverUrl)})` }
: null;
const hasOutline = outline.length > 0;
return (
{coverStyle ? (
) : null}
{icon ? (
) : null}
{title}
{hasOutline ? (
) : null}
{children}
{site.currentIsHome ? null : (
)}
}
rail={hasOutline ? : undefined}
railBalance="content"
/>
);
}
export function NotFoundDocument() {
const header = readSitesHeaderRenderState();
const site = header
? { workspaceName: header.workspaceName, workspaceIcon: header.workspaceIcon, homeHref: header.homeHref }
: null;
const heading = site ? "Nothing here to read." : "Nothing here.";
const sub = site ? "This page is not published, or never was." : "This URL doesn't point to a bland site.";
const ctaLabel = site ? `Back to ${site.workspaceName}` : "Visit bland.tools";
const ctaHref = site ? site.homeHref : "https://bland.tools";
const docTitle = site ? `Not found - ${site.workspaceName}` : "Not found - bland";
return (
);
}
export function BuildingDocument() {
const header = readSitesHeaderRenderState();
const site = header
? { workspaceName: header.workspaceName, workspaceIcon: header.workspaceIcon, homeHref: header.homeHref }
: null;
const ctaLabel = site ? `Back to ${site.workspaceName}` : "Visit bland.tools";
const ctaHref = site ? site.homeHref : "https://bland.tools";
const docTitle = site ? `Preparing page - ${site.workspaceName}` : "Preparing page - bland";
return (
);
}
function SiteStatusDocument({
mark,
variantClass,
heading,
sub,
ctaLabel,
ctaHref,
docTitle,
showHeader,
}: {
mark: string;
variantClass: string;
heading: string;
sub: string;
ctaLabel: string;
ctaHref: string;
docTitle: string;
showHeader: boolean;
}) {
return (
{showHeader ? : null}
);
}
export function ApexDocument() {
return (
bland.
);
}
export function renderSiteNotFoundDocumentHtml(props: NotFoundDocumentProps): string {
return runWithSitesReactRenderContext(
createSitesNotFoundRenderContext(props),
() => `${renderToStaticMarkup()}`,
);
}
export function renderSiteBuildingDocumentHtml(props: NotFoundDocumentProps): string {
return runWithSitesReactRenderContext(
createSitesNotFoundRenderContext(props),
() => `${renderToStaticMarkup()}`,
);
}
export function renderApexDocumentHtml(props: ApexDocumentProps): string {
return runWithSitesReactRenderContext(
createSitesApexRenderContext(props),
() => `${renderToStaticMarkup()}`,
);
}
export function renderRobotsTxt(): string {
return "User-agent: *\nAllow: /\n";
}