41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
// Path: Frontend/src/entry-server.tsx
|
|
|
|
// @refresh reload
|
|
import { createHandler, StartServer } from "@solidjs/start/server";
|
|
|
|
const themeBootstrapScript = `
|
|
(() => {
|
|
try {
|
|
const storageKey = "theme";
|
|
const stored = localStorage.getItem(storageKey);
|
|
const theme = stored === "light" || stored === "dark"
|
|
? stored
|
|
: (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
|
|
document.documentElement.setAttribute("data-theme", theme);
|
|
} catch {
|
|
document.documentElement.setAttribute("data-theme", "light");
|
|
}
|
|
})();
|
|
`;
|
|
|
|
export default createHandler(() => (
|
|
<StartServer
|
|
document={({ assets, children, scripts }) => (
|
|
<html lang="en" data-theme="light">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<link rel="icon" href="/favicon.ico" />
|
|
<script innerHTML={themeBootstrapScript} />
|
|
{assets}
|
|
</head>
|
|
<body>
|
|
<div id="app">{children}</div>
|
|
{scripts}
|
|
</body>
|
|
</html>
|
|
)}
|
|
/>
|
|
));
|