Skip to content

Commit

Permalink
feat: embed main.css (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc authored Dec 22, 2024
1 parent 363b1ae commit 0c017f0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/html/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ import { environment } from '../environment'
import { ReadyUpDialog } from '../queue/views/html/ready-up-dialog'
import Html from '@kitajs/html'
import { FlashMessages } from './components/flash-messages'
import { bundle } from './bundle'
import { resolve } from 'path'
import { requestContext } from '@fastify/request-context'
import { embed } from './embed'

const mainCss = await bundle(resolve(import.meta.dirname, 'styles', 'main.css'))

export function Layout(
export async function Layout(
props?: Html.PropsWithChildren<{
title?: string
embedStyle?: string
Expand Down Expand Up @@ -38,6 +35,8 @@ export function Layout(
)
}

const safeCss = await embed(resolve(import.meta.dirname, 'styles', 'main.css'))

return (
<>
<html lang="en">
Expand All @@ -46,7 +45,7 @@ export function Layout(
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<script src="/js/main.js" type="module"></script>
<link href={mainCss} rel="stylesheet" hx-preserve></link>
<style type="text/css">{safeCss}</style>
{title}
</head>
<body hx-ext="ws,head-support" ws-connect="/ws" class="h-screen" hx-boost="true">
Expand Down

0 comments on commit 0c017f0

Please sign in to comment.