feat: insert registry to head

This commit is contained in:
Ayo 2023-10-08 02:24:30 +02:00
parent bd66b1ccae
commit 325ecf36c6
3 changed files with 8 additions and 12 deletions

View file

@ -10,6 +10,14 @@ export default eventHandler(async (event) => {
if (!html) html = await useStorage().getItem(fallback);
if (!html) html = await useStorage().getItem(getPath("/404.html"));
// insert registry to head
html = html
.toString()
.replace(
"</head>",
'<script type="module" src="./.output/registry.js"></script></head>'
);
return html ?? new Response("Not found", { status: 404 });
});

View file

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>About Me</title>
</head>
<body>
<h1>About Me</h1>
</body>
</html>

View file

@ -4,7 +4,6 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello Nitro</title>
<script type="module" src="./.output/registry.js"></script>
</head>
<body>
<div>