doccupine 0.0.149 → 0.0.150
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/dist/lib/layout.js +26 -8
- package/package.json +1 -1
package/dist/lib/layout.js
CHANGED
|
@@ -90,14 +90,20 @@ function fontDeclLine(fontConfig) {
|
|
|
90
90
|
// and seeding the cookie so Cherry's ClientThemeProvider reconciles against
|
|
91
91
|
// the same answer on mount instead of flipping the class back.
|
|
92
92
|
//
|
|
93
|
-
// The script also
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
93
|
+
// The script also retargets the theme-color meta from the resolved mode. The
|
|
94
|
+
// meta itself is server-rendered in the layout below, because Safari only
|
|
95
|
+
// tints reliably from a tag present in the parsed HTML - a meta created by
|
|
96
|
+
// script is honored inconsistently or not at all - while it does track
|
|
97
|
+
// content updates to an existing tag. It cannot be emitted as
|
|
98
|
+
// OS-scheme-scoped SSR metas (Next's viewport export): the site's mode is
|
|
99
|
+
// cookie-based, so a dark site on a light-OS device would show the wrong
|
|
100
|
+
// browser chrome until hydration - a visible flash on every load. Pages are
|
|
101
|
+
// static, so the server cannot know the mode either: the SSR value is the
|
|
102
|
+
// light primary and this script corrects it before first paint. The \${...}
|
|
103
|
+
// palette interpolations below are escaped so they resolve in the generated
|
|
104
|
+
// layout, at app build time, from the imported theme palettes. The token
|
|
105
|
+
// must match the provider's $themeColor (primary), so the pre-paint chrome
|
|
106
|
+
// color equals what Cherry syncs after hydration.
|
|
101
107
|
const THEME_INIT_SCRIPT = `(function(){try{var c=document.cookie.split(";").map(function(s){return s.trim();}).find(function(s){return s.indexOf("theme=")===0;});var v=c?c.split("=")[1]:null;var d=v?v==="dark":(window.matchMedia&&window.matchMedia("(prefers-color-scheme:dark)").matches);if(!v){document.cookie="theme="+(d?"dark":"light")+";path=/;max-age=31536000;SameSite=Lax";}var r=document.documentElement;r.dataset.theme=d?"dark":"light";if(d){r.classList.add("dark");}var m=document.querySelector('meta[name="theme-color"]');if(!m){m=document.createElement("meta");m.name="theme-color";document.head.appendChild(m);}m.content=d?"\${colorsDark.primary}":"\${colorsLight.primary}";}catch(e){}})();`;
|
|
102
108
|
/**
|
|
103
109
|
* Root layout ("app/layout.tsx"). Minimal shell: html/body, fonts, the theme
|
|
@@ -153,6 +159,18 @@ export default function RootLayout({
|
|
|
153
159
|
return (
|
|
154
160
|
<html lang="en" suppressHydrationWarning>
|
|
155
161
|
<head>
|
|
162
|
+
{/* Server-rendered so Safari has a real tag to tint from: WebKit
|
|
163
|
+
honors a theme-color meta created by script inconsistently, but
|
|
164
|
+
reliably tracks content updates to an existing one. Pages are
|
|
165
|
+
static, so the value is the light primary; the blocking script
|
|
166
|
+
below corrects it before first paint and Cherry keeps it in sync
|
|
167
|
+
after hydration. suppressHydrationWarning: the script edits
|
|
168
|
+
content before React hydrates. */}
|
|
169
|
+
<meta
|
|
170
|
+
name="theme-color"
|
|
171
|
+
content={colorsLight.primary}
|
|
172
|
+
suppressHydrationWarning
|
|
173
|
+
/>
|
|
156
174
|
{/* Resolves dark mode before the first paint by stamping data-theme
|
|
157
175
|
on <html>, which flips the CSS variables in GlobalStyles.
|
|
158
176
|
Inlined as a plain <script> (not next/script) so it ships in the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doccupine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.150",
|
|
4
4
|
"description": "Free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|