package main import ( "context" "git.dev.alexdunmow.com/block/core/templates/bn" ) // PageData carries data parsed off the doc map for the four page templates. // This is the same shape gotham uses; the renderers below differ only in // slot composition and column widths. type PageData struct { Title string Slots map[string]string ThemeMode string ThemeCSS string SiteSettings bn.SiteSettingsData PageMeta bn.PageMeta StructuredData string CSSHash string PageviewNonce string EngagementConfig bn.EngagementConfig } func parseEditorialPageData(doc map[string]any) PageData { title := "Untitled" if t, ok := doc["title"].(string); ok { title = t } slots := make(map[string]string) if s, ok := doc["slots"].(map[string]string); ok { slots = s } themeCSS := "" if tc, ok := doc["theme_css"].(string); ok { themeCSS = tc } structuredData := "" if sd, ok := doc["structured_data"].(string); ok { structuredData = sd } cssHash := "" if ch, ok := doc["css_hash"].(string); ok { cssHash = ch } pageviewNonce := "" if pn, ok := doc["pageview_nonce"].(string); ok { pageviewNonce = pn } themeMode := "light" if tm, ok := doc["theme_mode"].(string); ok && tm != "" { themeMode = tm } siteSettings := bn.ParseSiteSettings(doc) pageMeta := bn.ParsePageMeta(doc) engagementConfig := bn.ParseEngagementConfig(doc) return PageData{ Title: title, Slots: slots, ThemeMode: themeMode, ThemeCSS: themeCSS, SiteSettings: siteSettings, PageMeta: pageMeta, StructuredData: structuredData, CSSHash: cssHash, PageviewNonce: pageviewNonce, EngagementConfig: engagementConfig, } } // Default editorial page — masthead header, narrow main column, footer. templ Editorial(data PageData) { @bn.Head(bn.HeadData{ Title: data.Title, Settings: data.SiteSettings, PageMeta: data.PageMeta, ThemeMode: data.ThemeMode, ThemeCSS: data.ThemeCSS, PluginStyles: []string{}, StructuredData: data.StructuredData, CSSHash: data.CSSHash, PageviewNonce: data.PageviewNonce, EngagementConfig: data.EngagementConfig, }) @bn.AdminBypassBanner(data.SiteSettings)
@templ.Raw(data.Slots["header"])
if main, ok := data.Slots["main"]; ok && main != "" { @templ.Raw(main) } else {

No content blocks assigned to this page.

}
@bn.BodyEnd(data.SiteSettings) } // Section-front (landing) — stacked masthead, lead story, river, footer. templ EditorialLanding(data PageData) { @bn.Head(bn.HeadData{ Title: data.Title, Settings: data.SiteSettings, PageMeta: data.PageMeta, ThemeMode: data.ThemeMode, ThemeCSS: data.ThemeCSS, PluginStyles: []string{}, StructuredData: data.StructuredData, CSSHash: data.CSSHash, PageviewNonce: data.PageviewNonce, EngagementConfig: data.EngagementConfig, }) @bn.AdminBypassBanner(data.SiteSettings)
@templ.Raw(data.Slots["masthead"])
@templ.Raw(data.Slots["lead"])
@templ.Raw(data.Slots["river"])
@bn.BodyEnd(data.SiteSettings) } // Article — masthead, byline, narrow main column with drop cap, marginalia // rail, footer. The grid collapses to a single column below 1024px. templ EditorialArticle(data PageData) { @bn.Head(bn.HeadData{ Title: data.Title, Settings: data.SiteSettings, PageMeta: data.PageMeta, ThemeMode: data.ThemeMode, ThemeCSS: data.ThemeCSS, PluginStyles: []string{}, StructuredData: data.StructuredData, CSSHash: data.CSSHash, PageviewNonce: data.PageviewNonce, EngagementConfig: data.EngagementConfig, }) @bn.AdminBypassBanner(data.SiteSettings)
@templ.Raw(data.Slots["header"])
@templ.Raw(data.Slots["byline"])
if main, ok := data.Slots["main"]; ok && main != "" { @templ.Raw(main) } else {

No content blocks assigned to this page.

}
@bn.BodyEnd(data.SiteSettings) } // Full-width — edge-to-edge content for photo essays and data graphics. templ EditorialFullWidth(data PageData) { @bn.Head(bn.HeadData{ Title: data.Title, Settings: data.SiteSettings, PageMeta: data.PageMeta, ThemeMode: data.ThemeMode, ThemeCSS: data.ThemeCSS, PluginStyles: []string{}, StructuredData: data.StructuredData, CSSHash: data.CSSHash, PageviewNonce: data.PageviewNonce, EngagementConfig: data.EngagementConfig, }) @bn.AdminBypassBanner(data.SiteSettings)
@templ.Raw(data.Slots["header"])
if main, ok := data.Slots["main"]; ok && main != "" { @templ.Raw(main) } else {

No content blocks assigned to this page.

}
@bn.BodyEnd(data.SiteSettings) } func RenderEditorial(ctx context.Context, doc map[string]any) templ.Component { return Editorial(parseEditorialPageData(doc)) } func RenderEditorialLanding(ctx context.Context, doc map[string]any) templ.Component { return EditorialLanding(parseEditorialPageData(doc)) } func RenderEditorialArticle(ctx context.Context, doc map[string]any) templ.Component { return EditorialArticle(parseEditorialPageData(doc)) } func RenderEditorialFullWidth(ctx context.Context, doc map[string]any) templ.Component { return EditorialFullWidth(parseEditorialPageData(doc)) }