Skip to content

Commit

Permalink
deploy: 5374a62
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] committed Jan 17, 2025
0 parents commit 3717a39
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 0 deletions.
Empty file added .nojekyll
Empty file.
Binary file added assets/banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions index.html

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('./sw.js')
.then(() => navigator.serviceWorker.ready)
.then(() => {
const $elemList = document.querySelectorAll('[data-blurhash]');
for (const $elem of $elemList) {
const blurhash = $elem.dataset.blurhash;
$elem.style.backgroundSize = `100% 100%`;
$elem.style.backgroundImage = `url(/.blurhash/${encodeURIComponent(blurhash)})`;
}
});
}
23 changes: 23 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@import url(https://unpkg.com/modern-css-reset@1.4.0/dist/reset.min.css);
@import url(https://unpkg.com/github-markdown-css@4.0.0/github-markdown.css);
@import url(https://unpkg.com/prism-themes@1.9.0/themes/prism-nord.min.css);

body {
padding: 64px;
max-width: 1024px;
margin: auto;
}

@media screen and (max-width: 630px) {
body {
padding: 32px;
}
}

h1 {
text-align: center;
}

p img {
display: inline;
}
35 changes: 35 additions & 0 deletions sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
importScripts('https://unpkg.com/blurhash-sw@1.0.15/dist/index.js');

blurhashSW({
routeUrl: '/.blurhash/:blurhash',
width: 32,
height: 32,
});

self.addEventListener('install', (ev) => {
ev.waitUntil(self.skipWaiting());
});

self.addEventListener('activate', (ev) => {
ev.waitUntil(self.clients.claim());
});

self.addEventListener('fetch', (/** @type {FetchEvent} */ ev) => {
const url = new URL(ev.request.url);
const delay = parseInt(url.searchParams.get('__delay__'));

if (Number.isFinite(delay)) {
return ev.respondWith(
Promise.all([
fetch(ev.request, { cache: 'no-store', mode: 'cors', credentials: 'omit' }).then((res) => {
return new Response(res.body, {
headers: new Headers([...res.headers, ['Cache-Control', 'no-store']]),
});
}),
new Promise((resolve) => setTimeout(resolve, delay)),
]).then(([res]) => res),
);
} else {
return;
}
});

0 comments on commit 3717a39

Please sign in to comment.