|
1 | 1 | import { Archivo, Bricolage_Grotesque, IBM_Plex_Mono } from 'next/font/google'; |
2 | | -import { buildMetadata, buildThemeStyle } from '@ogs-tech/press-web'; |
| 2 | +import { buildMetadata, buildThemeStyle, getSiteConfig } from '@ogs-tech/press-web'; |
3 | 3 | import '@ogs-tech/press-web/theme.css'; |
4 | | -import { config } from '../press-config'; |
| 4 | +import { buildTime } from '../press-config'; |
5 | 5 |
|
6 | | -// Default-theme fonts, loaded + optimized by next/font at build time (Spec §6). |
7 | | -// Each exposes a CSS variable consumed by theme.css with a fallback: |
| 6 | +// Default-theme fonts, loaded + optimized by next/font at build time. Each exposes |
| 7 | +// a CSS variable consumed by theme.css with a fallback: |
8 | 8 | // font-family: var(--press-font-body, var(--press-font-body-default)) |
9 | | -// so an adopter override (emitted by buildThemeStyle) wins, else the optimized |
10 | | -// default applies. Overriding theme.fonts.* sets the family string only — loading |
11 | | -// that family is the adopter's responsibility. |
| 9 | +// so a Site Settings font override (emitted by buildThemeStyle) wins, else the |
| 10 | +// optimized default applies. Build-time families are still owned by press.config. |
12 | 11 | const display = Bricolage_Grotesque({ subsets: ['latin'], display: 'swap', variable: '--press-font-display-default' }); |
13 | 12 | const body = Archivo({ subsets: ['latin'], display: 'swap', variable: '--press-font-body-default' }); |
14 | 13 | const mono = IBM_Plex_Mono({ subsets: ['latin'], weight: ['400', '500'], display: 'swap', variable: '--press-font-mono-default' }); |
15 | 14 |
|
16 | 15 | const fontVars = `${display.variable} ${body.variable} ${mono.variable}`; |
17 | 16 |
|
18 | | -// Brand defaults, no page: title = seo.defaultTitle, plus the favicon icon. |
19 | | -export const metadata = buildMetadata(config, null); |
| 17 | +// Brand defaults, no page: title = seo.defaultTitle + favicon. Fetched at runtime |
| 18 | +// from the CMS (ISR ~60s) so editor changes appear without a redeploy. |
| 19 | +export async function generateMetadata() { |
| 20 | + return buildMetadata(await getSiteConfig(buildTime), null); |
| 21 | +} |
20 | 22 |
|
21 | | -export default function RootLayout({ children }: { children: React.ReactNode }) { |
| 23 | +export default async function RootLayout({ children }: { children: React.ReactNode }) { |
| 24 | + const site = await getSiteConfig(buildTime); |
22 | 25 | return ( |
23 | | - <html lang={config.site.locale} data-theme={config.theme.name} className={fontVars}> |
| 26 | + <html lang={site.site.locale} data-theme={buildTime.theme.name} className={fontVars}> |
24 | 27 | <head> |
25 | | - {/* The single injection point for token values (Spec §0). */} |
26 | | - <style dangerouslySetInnerHTML={{ __html: buildThemeStyle(config) }} /> |
| 28 | + {/* The single injection point for token values (CMS-sourced or DEFAULT_THEME). */} |
| 29 | + <style dangerouslySetInnerHTML={{ __html: buildThemeStyle(site) }} /> |
27 | 30 | </head> |
28 | 31 | <body> |
29 | 32 | <header> |
30 | 33 | <a href="/"> |
31 | | - {config.brand.logo ? <img src={config.brand.logo} alt="" /> : null} |
32 | | - <span>{config.brand.name}</span> |
| 34 | + {site.brand.logo ? <img src={site.brand.logo} alt="" /> : null} |
| 35 | + <span>{site.brand.name}</span> |
33 | 36 | </a> |
34 | 37 | </header> |
35 | 38 | <main>{children}</main> |
36 | 39 | <footer> |
37 | 40 | <small> |
38 | | - {config.brand.name} · {new Date().getFullYear()} |
| 41 | + {site.brand.name} · {new Date().getFullYear()} |
39 | 42 | </small> |
40 | 43 | </footer> |
41 | 44 | </body> |
|
0 commit comments