import type { MkdnSiteConfig } from '../config/schema.ts' import type { MarkdownMeta, NavNode } from '../content/types.ts' import { buildThemeCss } from '../theme/build-css.ts' import { CLIENT_SCRIPTS } from '../client/scripts.ts' interface PageShellProps { renderedContent: string meta: MarkdownMeta config: MkdnSiteConfig nav?: NavNode currentSlug: string /** Raw markdown body — used for reading time calculation */ body?: string } /** * Render a full HTML page wrapping the markdown content. * This is pure SSR — no client-side React hydration required. */ export function renderPage (props: PageShellProps): string { const { renderedContent, meta, config, nav, currentSlug, body } = props const title = meta.title != null ? `${meta.title} — ${config.site.title}` : config.site.title const description = meta.description ?? config.site.description ?? '' const lang = config.site.lang ?? 'en' // Layout from frontmatter: 'default' | 'wide' | 'landing' | any custom value // - default: nav + content + optional ToC // - wide: nav visible, ToC hidden, content spans full width // - landing: no nav, no ToC, content centered at larger max-width const layout = typeof meta.layout === 'string' && meta.layout !== '' ? meta.layout : 'default' const isWide = layout === 'wide' const isLanding = layout === 'landing' const navHtml = (config.theme.showNav && nav != null && !isLanding) ? renderNav(nav, currentSlug, config) : '' const pageTitleHtml = (config.theme.pageTitle === true && meta.title != null) ? `
The page you\'re looking for doesn\'t exist.
', meta: { title: 'Not Found' }, config, currentSlug: '' }) } function renderNavHeader (config: MkdnSiteConfig): string { const { logo, logoText } = config.theme const imgHtml = logo != null ? `