Enable PWA (#2142) by lukew3

* add pwa files

* Added better 512px icon! (#2146)

* updated icon

Co-authored-by: Estebene <49330942+Estebene@users.noreply.github.com>
Co-authored-by: Jack <bartnikjack@gmail.com>
This commit is contained in:
Luke Weiler 2021-12-13 12:46:51 -05:00 committed by GitHub
parent ee143b4f12
commit 1bca5888f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View file

@ -54,6 +54,7 @@
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link rel="manifest" href="manifest.json" />
<meta name="name" content="Monkeytype" />
<meta name="image" content="https://monkeytype.com/mtsocial.png" />
<meta
@ -94,6 +95,11 @@
id="adScript"
async
></script>
<script>
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("sw.js");
}
</script>
</head>
<div class="customBackground"></div>

15
static/manifest.json Normal file
View file

@ -0,0 +1,15 @@
{
"short_name": "MT",
"name": "Monkeytype",
"start_url": "/",
"icons": [
{
"src": "/images/mt-icon-512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"background_color": "#323437",
"display": "standalone",
"theme_color": "#323437"
}

15
static/sw.js Normal file
View file

@ -0,0 +1,15 @@
self.addEventListener("install", function (event) {
event.waitUntil(
caches.open("sw-cache").then(function (cache) {
return cache.add("index.html");
})
);
});
self.addEventListener("fetch", function (event) {
event.respondWith(
caches.match(event.request).then(function (response) {
return response || fetch(event.request);
})
);
});