From f7cc2db225f9fac2f59fd9b11398303111fe3b49 Mon Sep 17 00:00:00 2001 From: satotake Date: Thu, 23 Jun 2022 21:38:57 +0900 Subject: [PATCH] fix: generate favicon.ico in init script (#278) Browsers try to get `/favicon.ico` by default. This request enters `[name].tsx` and returns greet unexpectedly. To fix this, the favicon is now fetched from `https://fresh.deno.dev` and saved into the `static` folder in the init script. --- init.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/init.ts b/init.ts index fca6492d..86bd3c58 100644 --- a/init.ts +++ b/init.ts @@ -233,6 +233,17 @@ await Deno.writeTextFile( STATIC_LOGO, ); +try { + const faviconArrayBuffer = await fetch("https://fresh.deno.dev/favicon.ico") + .then((d) => d.arrayBuffer()); + await Deno.writeFile( + join(directory, "static", "favicon.ico"), + new Uint8Array(faviconArrayBuffer), + ); +} catch { + // Skip this and be silent if there is a nework issue. +} + let MAIN_TS = `/// /// ///