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

View File

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

View File

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

View File

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