diff --git a/src/app.js b/src/app.js index 2eb3c17..4bb9eeb 100644 --- a/src/app.js +++ b/src/app.js @@ -20,6 +20,14 @@ function html(status, markup) { }; } +function text(status, body, contentType) { + return { + status, + headers: { "content-type": contentType || "text/plain; charset=utf-8" }, + body, + }; +} + function parseJSON(rawBody) { if (!rawBody) { return {}; @@ -112,6 +120,30 @@ function buildApp({ config }) { return json(200, { ok: true }); } + if (method === "GET" && path === "/manifest.webmanifest") { + return text( + 200, + JSON.stringify({ + name: "X Article to Audio", + short_name: "XArtAudio", + start_url: "/", + display: "standalone", + background_color: "#1d232a", + theme_color: "#1d232a", + icons: [], + }), + "application/manifest+json; charset=utf-8", + ); + } + + if (method === "GET" && path === "/sw.js") { + return text( + 200, + "self.addEventListener('install', () => self.skipWaiting()); self.addEventListener('activate', () => self.clients.claim());", + "application/javascript; charset=utf-8", + ); + } + if (method === "GET" && path === "/") { return html(200, renderHomePage({ authenticated: Boolean(userId), diff --git a/src/views/pages.js b/src/views/pages.js index 20d31d0..1467d8b 100644 --- a/src/views/pages.js +++ b/src/views/pages.js @@ -16,12 +16,19 @@ function layout({ title, content }) {