Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously an unversioned directory inside ~/src/blockninja-themes/pastel-dream. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
253 lines
8.0 KiB
Plaintext
253 lines
8.0 KiB
Plaintext
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.dev.alexdunmow.com/block/core/templates/bn"
|
|
)
|
|
|
|
// PastelPageData carries the per-render page context.
|
|
type PastelPageData 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
|
|
}
|
|
|
|
// parsePastelPageData converts the wire-format doc map into a PastelPageData.
|
|
// It is lenient: missing fields fall back to sensible defaults so empty pages
|
|
// render without panicking.
|
|
func parsePastelPageData(doc map[string]any) PastelPageData {
|
|
title := "Untitled"
|
|
if t, ok := doc["title"].(string); ok && t != "" {
|
|
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
|
|
}
|
|
|
|
return PastelPageData{
|
|
Title: title,
|
|
Slots: slots,
|
|
ThemeMode: themeMode,
|
|
ThemeCSS: themeCSS,
|
|
SiteSettings: bn.ParseSiteSettings(doc),
|
|
PageMeta: bn.ParsePageMeta(doc),
|
|
StructuredData: structuredData,
|
|
CSSHash: cssHash,
|
|
PageviewNonce: pageviewNonce,
|
|
EngagementConfig: bn.ParseEngagementConfig(doc),
|
|
}
|
|
}
|
|
|
|
// PastelDefault is the standard pastel-dream page template — masthead, main
|
|
// column, and footer. Used by both `default` and (with a slightly wider main)
|
|
// the `full-width` template.
|
|
templ PastelDefault(data PastelPageData) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
@bn.Head(bn.HeadData{
|
|
Title: data.Title,
|
|
Settings: data.SiteSettings,
|
|
PageMeta: data.PageMeta,
|
|
ThemeMode: data.ThemeMode,
|
|
ThemeCSS: data.ThemeCSS,
|
|
PluginStyles: []string{"/templates/pastel-dream/style.css"},
|
|
StructuredData: data.StructuredData,
|
|
CSSHash: data.CSSHash,
|
|
PageviewNonce: data.PageviewNonce,
|
|
EngagementConfig: data.EngagementConfig,
|
|
})
|
|
<body class="font-body antialiased min-h-screen flex flex-col" style="background-color: hsl(var(--background)); color: hsl(var(--foreground));">
|
|
@bn.AdminBypassBanner(data.SiteSettings)
|
|
<header class="w-full">
|
|
@templ.Raw(data.Slots["header"])
|
|
</header>
|
|
<main class="flex-grow w-full max-w-4xl mx-auto px-4 py-12">
|
|
if main, ok := data.Slots["main"]; ok && main != "" {
|
|
@templ.Raw(main)
|
|
} else {
|
|
<div class="py-20 text-center font-body" style="color: hsl(var(--muted-foreground));">
|
|
<p>This page is still resting. Add a block to begin.</p>
|
|
</div>
|
|
}
|
|
</main>
|
|
<footer class="w-full mt-auto">
|
|
@templ.Raw(data.Slots["footer"])
|
|
</footer>
|
|
@bn.BodyEnd(data.SiteSettings)
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
// PastelLanding is the marketing landing layout — full-width hero, body,
|
|
// affirmation CTA, footer.
|
|
templ PastelLanding(data PastelPageData) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
@bn.Head(bn.HeadData{
|
|
Title: data.Title,
|
|
Settings: data.SiteSettings,
|
|
PageMeta: data.PageMeta,
|
|
ThemeMode: data.ThemeMode,
|
|
ThemeCSS: data.ThemeCSS,
|
|
PluginStyles: []string{"/templates/pastel-dream/style.css"},
|
|
StructuredData: data.StructuredData,
|
|
CSSHash: data.CSSHash,
|
|
PageviewNonce: data.PageviewNonce,
|
|
EngagementConfig: data.EngagementConfig,
|
|
})
|
|
<body class="font-body antialiased min-h-screen flex flex-col" style="background-color: hsl(var(--background)); color: hsl(var(--foreground));">
|
|
@bn.AdminBypassBanner(data.SiteSettings)
|
|
<section class="w-full">
|
|
@templ.Raw(data.Slots["hero"])
|
|
</section>
|
|
<main class="flex-grow w-full">
|
|
if main, ok := data.Slots["main"]; ok && main != "" {
|
|
<div class="max-w-6xl mx-auto px-4 py-20">
|
|
@templ.Raw(main)
|
|
</div>
|
|
}
|
|
</main>
|
|
<section class="w-full">
|
|
@templ.Raw(data.Slots["cta"])
|
|
</section>
|
|
<footer class="w-full mt-auto">
|
|
@templ.Raw(data.Slots["footer"])
|
|
</footer>
|
|
@bn.BodyEnd(data.SiteSettings)
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
// PastelArticle is the narrow reading-room layout for editorial posts.
|
|
templ PastelArticle(data PastelPageData) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
@bn.Head(bn.HeadData{
|
|
Title: data.Title,
|
|
Settings: data.SiteSettings,
|
|
PageMeta: data.PageMeta,
|
|
ThemeMode: data.ThemeMode,
|
|
ThemeCSS: data.ThemeCSS,
|
|
PluginStyles: []string{"/templates/pastel-dream/style.css"},
|
|
StructuredData: data.StructuredData,
|
|
CSSHash: data.CSSHash,
|
|
PageviewNonce: data.PageviewNonce,
|
|
EngagementConfig: data.EngagementConfig,
|
|
})
|
|
<body class="font-body antialiased min-h-screen flex flex-col" style="background-color: hsl(var(--background)); color: hsl(var(--foreground));">
|
|
@bn.AdminBypassBanner(data.SiteSettings)
|
|
<header class="w-full">
|
|
@templ.Raw(data.Slots["header"])
|
|
</header>
|
|
<main class="flex-grow w-full max-w-2xl mx-auto px-4 py-16">
|
|
if main, ok := data.Slots["main"]; ok && main != "" {
|
|
<article class="font-body prose max-w-none" style="line-height: 1.75; color: hsl(var(--foreground));">
|
|
@templ.Raw(main)
|
|
</article>
|
|
} else {
|
|
<div class="py-20 text-center" style="color: hsl(var(--muted-foreground));">
|
|
<p>This page is still resting. Add a block to begin.</p>
|
|
</div>
|
|
}
|
|
</main>
|
|
<footer class="w-full mt-auto">
|
|
@templ.Raw(data.Slots["footer"])
|
|
</footer>
|
|
@bn.BodyEnd(data.SiteSettings)
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
// PastelFullWidth is the edge-to-edge layout for galleries and seasonal looks.
|
|
templ PastelFullWidth(data PastelPageData) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
@bn.Head(bn.HeadData{
|
|
Title: data.Title,
|
|
Settings: data.SiteSettings,
|
|
PageMeta: data.PageMeta,
|
|
ThemeMode: data.ThemeMode,
|
|
ThemeCSS: data.ThemeCSS,
|
|
PluginStyles: []string{"/templates/pastel-dream/style.css"},
|
|
StructuredData: data.StructuredData,
|
|
CSSHash: data.CSSHash,
|
|
PageviewNonce: data.PageviewNonce,
|
|
EngagementConfig: data.EngagementConfig,
|
|
})
|
|
<body class="font-body antialiased min-h-screen flex flex-col" style="background-color: hsl(var(--background)); color: hsl(var(--foreground));">
|
|
@bn.AdminBypassBanner(data.SiteSettings)
|
|
<header class="w-full">
|
|
@templ.Raw(data.Slots["header"])
|
|
</header>
|
|
<main class="flex-grow w-full">
|
|
if main, ok := data.Slots["main"]; ok && main != "" {
|
|
@templ.Raw(main)
|
|
} else {
|
|
<div class="max-w-4xl mx-auto py-20 px-4 text-center" style="color: hsl(var(--muted-foreground));">
|
|
<p>This page is still resting. Add a block to begin.</p>
|
|
</div>
|
|
}
|
|
</main>
|
|
<footer class="w-full mt-auto">
|
|
@templ.Raw(data.Slots["footer"])
|
|
</footer>
|
|
@bn.BodyEnd(data.SiteSettings)
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
// RenderPastelDefault is the registered render entry for the default template.
|
|
func RenderPastelDefault(ctx context.Context, doc map[string]any) templ.Component {
|
|
return PastelDefault(parsePastelPageData(doc))
|
|
}
|
|
|
|
// RenderPastelLanding is the registered render entry for the landing template.
|
|
func RenderPastelLanding(ctx context.Context, doc map[string]any) templ.Component {
|
|
return PastelLanding(parsePastelPageData(doc))
|
|
}
|
|
|
|
// RenderPastelArticle is the registered render entry for the article template.
|
|
func RenderPastelArticle(ctx context.Context, doc map[string]any) templ.Component {
|
|
return PastelArticle(parsePastelPageData(doc))
|
|
}
|
|
|
|
// RenderPastelFullWidth is the registered render entry for the full-width template.
|
|
func RenderPastelFullWidth(ctx context.Context, doc map[string]any) templ.Component {
|
|
return PastelFullWidth(parsePastelPageData(doc))
|
|
}
|