website/main.ts

27 lines
652 B
TypeScript

import { App, fsRoutes, staticFiles } from 'fresh'
import { type State } from './utils.ts'
import { smartStylesheetPlugin } from ':plugins/SmartStylesheet.tsx'
export const app = new App<State>()
//disable this unsupprted path to prevent static file render error
app.use((ctx) =>
ctx.url.pathname === '/.well-known/appspecific/com.chrome.devtools.json'
? new Response(null, { status: 404 })
: ctx.next()
)
app.use(staticFiles())
smartStylesheetPlugin(app)
await fsRoutes(app, {
dir: './',
loadIsland: (path) => import(`./islands/${path}`),
loadRoute: (path) => import(`./routes/${path}`),
})
if (import.meta.main) {
await app.listen()
}