@koehler8/cms 1.0.0-beta.10 → 1.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/manifest.schema.json +1 -1
- package/package.json +1 -1
- package/src/main.js +19 -4
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -41,14 +41,29 @@ const extractThemeKey = (siteData) => {
|
|
|
41
41
|
|
|
42
42
|
const applySiteTheme = (themeKey, head) => {
|
|
43
43
|
const normalized = normalizeThemeKey(themeKey);
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
// No theme configured — leave `<html>` without `data-site-theme` so
|
|
46
|
+
// none of the `:root[data-site-theme="X"]` rules in the bundled
|
|
47
|
+
// virtual:cms-theme-vars.css apply. Components fall back to their
|
|
48
|
+
// hardcoded CSS defaults. Sites that intentionally want the bundled
|
|
49
|
+
// `base` palette must opt in via `"theme": "base"` in site.json (or
|
|
50
|
+
// any locale's site.json).
|
|
51
|
+
//
|
|
52
|
+
// (The implicit auto-apply of `base` was removed in 1.0.0-beta.12.
|
|
53
|
+
// It hid configuration mistakes — sites that registered a theme but
|
|
54
|
+
// forgot to activate it silently rendered with `base` instead of the
|
|
55
|
+
// theme they intended. Surfacing the misconfiguration via "no theme
|
|
56
|
+
// applied" is more honest.)
|
|
57
|
+
if (!normalized) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
45
60
|
|
|
46
61
|
// Push the html attribute via @unhead so `data-site-theme="X"` lands
|
|
47
62
|
// in the SSR-rendered HTML *before* Vue hydrates. Theme CSS selectors
|
|
48
63
|
// (`:root[data-site-theme="X"]`) then apply during the very first
|
|
49
64
|
// paint, eliminating the need for site-side critical-CSS overrides.
|
|
50
65
|
if (head && typeof head.push === 'function') {
|
|
51
|
-
head.push({ htmlAttrs: { 'data-site-theme':
|
|
66
|
+
head.push({ htmlAttrs: { 'data-site-theme': normalized } });
|
|
52
67
|
}
|
|
53
68
|
|
|
54
69
|
// Client only: also set the attribute imperatively (so runtime theme
|
|
@@ -56,8 +71,8 @@ const applySiteTheme = (themeKey, head) => {
|
|
|
56
71
|
// for themes that ship JS-only design tokens (e.g. the bundled `base`
|
|
57
72
|
// theme has no theme.css).
|
|
58
73
|
if (typeof document !== 'undefined') {
|
|
59
|
-
document.documentElement.dataset.siteTheme =
|
|
60
|
-
applyThemeVariables(
|
|
74
|
+
document.documentElement.dataset.siteTheme = normalized;
|
|
75
|
+
applyThemeVariables(normalized);
|
|
61
76
|
}
|
|
62
77
|
};
|
|
63
78
|
|