Closed1

Hono + UnoCSS

nakasyounakasyou
import { Hono } from '@hono/hono'
import { createGenerator } from '@unocss/core'
import presetUno from '@unocss/preset-uno'

const app = new Hono()

const generator = createGenerator({ presets: [presetUno()] })
app.use(async (c, next) => {
  c.setRenderer(async content => {
    const string = (await content).toString()
    const style = await uno.generate(content, { preflights: false })
    return c.html(<html>
      <head>
        {/* 略 */}
        <style dangerouslySetInnerHTML={{ __html: style.css }}  />
      </head>
      <body>
        {content}
      </body>
   </html>)
  })
  await next()
})

app.get('/', c => {
  return c.render(<div class="text-2xl">Hello World</div>)
})
このスクラップは3ヶ月前にクローズされました