Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041import type { ParentProps } from "solid-js";import { HydrationScript } from "@solidjs/web";
// The document shell — the new index.html: picked up by the src/Document.*// convention, it wraps the app in the plugin's generated entries and must// render the full <html>. Head tags go here. It is compiled only into the// prerendered static shell and ships zero client-side JS: in client mode// <HydrationScript /> is stripped from the shell, and it activates when the// app flips to SSR (`ssr: true` in vite.config.ts) — no document changes// needed. Delete this file to fall back to the plugin's built-in shell.// The theme is applied by JS at boot, but the shell paints before that: this reads the same// two inputs the app does (the stored mode, then the machine while the mode is `system`) and// stamps `data-theme` in the same frame the stylesheet parses, so a light-theme listener never// sees a dark first frame. It mirrors `lib/theme/mode.ts`'s resolveTheme rather than// redeciding anything: the app's startThemeSync overwrites this a beat later and owns every// change after. Kept as a module constant (rather than a literal in the attribute) both to// read as the deliberate script it is and to keep it out of the `no-innerhtml` heuristic, which// checks HTML and this is the one legitimate `<script>` body in the shell.const THEME_BOOT = "try{var m=JSON.parse(localStorage.getItem('hackermusic.theme.v1'));var t=m==='light'||m==='dark'?m:(matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light');document.documentElement.dataset.theme=t}catch(e){}";
export default function Document(props: ParentProps) { return ( <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="color-scheme" content="light dark" /> {/* Applied inline before the app boots, so the first frame is already the right theme; a <script> body is JavaScript, so the innerHTML HTML-heuristic rule doesn't apply. */} {/* eslint-disable-next-line solid/no-innerhtml -- script body is JS, not HTML */} <script innerHTML={THEME_BOOT} /> <link rel="icon" href="/favicon.ico" /> <title>hackermusic</title> <HydrationScript /> </head> <body>{props.children}</body> </html> );}