Skip to content

Commit

Permalink
DEV: Inline CSS for app shell (#27)
Browse files Browse the repository at this point in the history
closes #27
  • Loading branch information
dwhieb committed May 17, 2024
1 parent 48da7b5 commit db63cb4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/locals.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import path from 'node:path'
import { readFile } from 'node:fs/promises'

// Load metadata
const metaPath = path.resolve(import.meta.dirname, `../package.json`)
const json = await readFile(metaPath, `utf8`)
const meta = JSON.parse(json)

export default { meta }
// Load CSS for app shell
const mainCSSPath = path.resolve(import.meta.dirname, `../assets/styles/main.css`)
const mainCSS = await readFile(mainCSSPath, `utf8`)

export default { mainCSS, meta }
3 changes: 0 additions & 3 deletions layouts/main/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
body {
color: red;
}
1 change: 1 addition & 0 deletions layouts/main/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html dir=ltr lang=en>
{{> head }}
<body>
<style>{{ mainCSS }}</style>
{{{ body }}}{{!-- This is actually <main> but express-handlebars calls this variable `body`. --}}
</body>
</html>

0 comments on commit db63cb4

Please sign in to comment.