1
Fork 0

Add favicon

This commit is contained in:
Tobias Berger 2023-06-29 13:27:41 +02:00
parent 0c45609a14
commit 996f4db048
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
2 changed files with 7 additions and 3 deletions

BIN
favicon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View file

@ -10,9 +10,14 @@ const HEADERS_STYLESHEET = {
"Content-Type": "text/css",
},
};
const HEADERS_FAVICON = {
headers: {
"Content-Type": "image/x-icon",
},
};
async function htmlDoc(body: string, head: string): Promise<string> {
return `<!DOCTYPE html><html><head><link rel=stylesheet href=style.css>${head}</head><body>${body}</body></html>`
return `<!DOCTYPE html><html><head><link rel=stylesheet href=style.css><link rel=icon type="image/x-icon" href=favicon.ico>${head}</head><body>${body}</body></html>`
}
async function createBoard(width: number, height: number, mines: number): Promise<string> {
@ -98,8 +103,7 @@ Bun.serve({
const url = new URL(request.url);
if (url.pathname === "/favicon.ico") {
// TODO: Add favicon
return new Response("Not found", { status: 404, statusText: "Not found" });
return new Response(await Bun.file("favicon.ico").arrayBuffer(), FAVICON_STYLESHEET);
}
if (url.pathname === "/style.css") {