package main import ( "context" "git.dev.alexdunmow.com/block/core/templates/bn" ) // PageData carries the data the Magazine Bold page templates render. 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 parseMagazineBoldPageData(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, } } // mbHead reuses the core head component with the magazine-bold plugin style sheet. templ mbHead(data PageData) { @bn.Head(bn.HeadData{ Title: data.Title, Settings: data.SiteSettings, PageMeta: data.PageMeta, ThemeMode: data.ThemeMode, ThemeCSS: data.ThemeCSS, PluginStyles: []string{"/templates/magazine-bold/style.css"}, StructuredData: data.StructuredData, CSSHash: data.CSSHash, PageviewNonce: data.PageviewNonce, EngagementConfig: data.EngagementConfig, }) } // MagazineBold — default page template. // Slots: masthead, main, colophon. templ MagazineBold(data PageData) { @mbHead(data) @bn.AdminBypassBanner(data.SiteSettings)
@templ.Raw(data.Slots["masthead"])
if main, ok := data.Slots["main"]; ok && main != "" { @templ.Raw(main) } else {
No content blocks assigned to this page.
}
@bn.BodyEnd(data.SiteSettings) } // MagazineBoldLanding — issue landing page template. // Slots: cover, secondary, main, colophon. templ MagazineBoldLanding(data PageData) { @mbHead(data) @bn.AdminBypassBanner(data.SiteSettings)
@templ.Raw(data.Slots["cover"])
@templ.Raw(data.Slots["secondary"])
if main, ok := data.Slots["main"]; ok && main != "" { @templ.Raw(main) } else {
No content blocks assigned to this page.
}
@bn.BodyEnd(data.SiteSettings) } // MagazineBoldArticle — long-form feature template with deck and pull-quote gutter. // Slots: masthead, deck, main, colophon. templ MagazineBoldArticle(data PageData) { @mbHead(data) @bn.AdminBypassBanner(data.SiteSettings)
@templ.Raw(data.Slots["masthead"])
@templ.Raw(data.Slots["deck"])
if main, ok := data.Slots["main"]; ok && main != "" {
@templ.Raw(main)
} else {
No content blocks assigned to this page.
}
@bn.BodyEnd(data.SiteSettings) } // MagazineBoldFullWidth — edge-to-edge photo-essay template. // Slots: masthead, main, colophon. templ MagazineBoldFullWidth(data PageData) { @mbHead(data) @bn.AdminBypassBanner(data.SiteSettings)
@templ.Raw(data.Slots["masthead"])
if main, ok := data.Slots["main"]; ok && main != "" { @templ.Raw(main) } else {
No content blocks assigned to this page.
}
@bn.BodyEnd(data.SiteSettings) } // RenderMagazineBold renders the default page. func RenderMagazineBold(ctx context.Context, doc map[string]any) templ.Component { return MagazineBold(parseMagazineBoldPageData(doc)) } // RenderMagazineBoldLanding renders the issue-landing page. func RenderMagazineBoldLanding(ctx context.Context, doc map[string]any) templ.Component { return MagazineBoldLanding(parseMagazineBoldPageData(doc)) } // RenderMagazineBoldArticle renders the long-form article page. func RenderMagazineBoldArticle(ctx context.Context, doc map[string]any) templ.Component { return MagazineBoldArticle(parseMagazineBoldPageData(doc)) } // RenderMagazineBoldFullWidth renders the edge-to-edge photo-essay page. func RenderMagazineBoldFullWidth(ctx context.Context, doc map[string]any) templ.Component { return MagazineBoldFullWidth(parseMagazineBoldPageData(doc)) }