Skip to content

Commit

Permalink
Adding Manifest and Service Worker
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKinlan committed Nov 7, 2021
1 parent 4885e8f commit 7e4c6f4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
6 changes: 4 additions & 2 deletions static/admin/index.html
Expand Up @@ -18,11 +18,13 @@
handler: ({ entry }) => {
const data = entry.get("data");
const title = data.get("title");
return data.set("slug", slugify(title, {lower: true}));

return data.set("slug", slugify(title, { lower: true }));
}
});

navigator.serviceWorker.register("./sw.sj")

</script>
</body>

Expand Down
14 changes: 14 additions & 0 deletions static/admin/manifest.json
@@ -0,0 +1,14 @@
{
"name": "Blog: Paul Kinlan - Admin",
"short_name": "Blog: Admin",
"start_url": "/admin/",
"theme_color": "#000000",
"background_color": "#000000",
"icons": [ {
"sizes": "192x192",
"src": "/images/me.png",
"type": "image/png"
}],
"display": "standalone",
"scope": "/admin/"
}
16 changes: 16 additions & 0 deletions static/admin/sw.js
@@ -0,0 +1,16 @@
onfetch = async (event) => {
if (event.request.method !== "POST") return;
if (event.request.url.startsWith("https://paul.kinlan.me/admin/") === false) {
return;
}

event.respondWith(Response.redirect("/admin/"));
};

oninstall = () => {
skipWaiting();
};

onactivate = () => {
clients.claim();
};

1 comment on commit 7e4c6f4

@vercel
Copy link

@vercel vercel bot commented on 7e4c6f4 Nov 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.