Add favicon
This commit is contained in:
parent
0c45609a14
commit
996f4db048
2 changed files with 7 additions and 3 deletions
BIN
favicon.ico
Executable file
BIN
favicon.ico
Executable file
Binary file not shown.
After Width: | Height: | Size: 109 KiB |
10
server.ts
10
server.ts
|
@ -10,9 +10,14 @@ const HEADERS_STYLESHEET = {
|
||||||
"Content-Type": "text/css",
|
"Content-Type": "text/css",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
const HEADERS_FAVICON = {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "image/x-icon",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
async function htmlDoc(body: string, head: string): Promise<string> {
|
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> {
|
async function createBoard(width: number, height: number, mines: number): Promise<string> {
|
||||||
|
@ -98,8 +103,7 @@ Bun.serve({
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
|
|
||||||
if (url.pathname === "/favicon.ico") {
|
if (url.pathname === "/favicon.ico") {
|
||||||
// TODO: Add favicon
|
return new Response(await Bun.file("favicon.ico").arrayBuffer(), FAVICON_STYLESHEET);
|
||||||
return new Response("Not found", { status: 404, statusText: "Not found" });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url.pathname === "/style.css") {
|
if (url.pathname === "/style.css") {
|
||||||
|
|
Loading…
Reference in a new issue