simpler init script for tools

This commit is contained in:
Chris Wanstrath 2026-02-04 08:35:16 -08:00
parent d8769b2d9d
commit 303d2dfc72
4 changed files with 8 additions and 7 deletions

View File

@ -1,6 +1,6 @@
import { Hype } from '@because/hype'
import { define, stylesToCSS } from '@because/forge'
import { baseStyles, initScript, theme } from '@because/toes/tools'
import { baseStyles, ToolScript, theme } from '@because/toes/tools'
import { readdir, stat } from 'fs/promises'
import { readFileSync } from 'fs'
import { join, extname, basename } from 'path'
@ -309,7 +309,7 @@ function Layout({ title, children, highlight, editable }: LayoutProps) {
</head>
<body>
<script dangerouslySetInnerHTML={{ __html: fileMemoryScript }} />
<script dangerouslySetInnerHTML={{ __html: initScript }} />
<ToolScript />
<Container>
{children}
</Container>

View File

@ -1,6 +1,6 @@
import { Hype } from '@because/hype'
import { define, stylesToCSS } from '@because/forge'
import { baseStyles, initScript, theme } from '@because/toes/tools'
import { baseStyles, ToolScript, theme } from '@because/toes/tools'
import { discoverCronJobs } from './lib/discovery'
import { scheduleJob, stopJob } from './lib/scheduler'
import { executeJob } from './lib/executor'
@ -183,7 +183,7 @@ function Layout({ title, children }: { title: string; children: Child }) {
<link rel="stylesheet" href="/styles.css" />
</head>
<body>
<script dangerouslySetInnerHTML={{ __html: initScript }} />
<ToolScript />
<Container>
{children}
</Container>

View File

@ -1,3 +1,2 @@
export { theme } from '../client/themes'
export { baseStyles, initScript } from './scripts'
export { define, stylesToCSS } from '@because/forge'
export { baseStyles, ToolScript } from './scripts.tsx'

View File

@ -1,6 +1,6 @@
import { theme } from '../client/themes'
export const initScript = `
const initScript = `
(function() {
var theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
document.body.setAttribute('data-theme', theme);
@ -29,3 +29,5 @@ body {
margin: 0;
}
`
export const ToolScript = () => <script dangerouslySetInnerHTML={{ __html: initScript }} />