Make Google Lighthouse more happy

main
idylls 2 years ago
parent fb1454b03f
commit 7078374ec2
Signed by: idylls
GPG Key ID: 8A7167CBC2CC9F0F

@ -8,6 +8,8 @@ const HttpService = object({
export const Configuration = object({
hostname: string().optional(),
port: number().optional(),
title: string().optional(),
description: string().optional(),
hosts: record(string()),
services: record(HttpService),
});

@ -27,22 +27,26 @@ const apiHandler = filter(
setHeaders([["content-type", "application/json"]], serve),
);
const root = (req: Request) => {
const root = async (req: Request) => {
if (!req.url.endsWith("/")) {
return null;
}
const config = await loadConfiguration();
return new Response(`
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="${config.description ?? config.title ?? "Statue - a simple status monitor"}">
<script type="module">
${frontend}
</script>
<style>
${style}
</style>
<title>Statue</title>
<title>${config.title ?? "Statue"}</title>
</head>
<body>
<noscript>
@ -51,7 +55,7 @@ const root = (req: Request) => {
</body>
</html>
`, {
headers: { "content-type": "text/html" },
headers: { "content-type": "text/html; charset=utf-8" },
});
};

Loading…
Cancel
Save