feat(pwabuilder-sw.js): Ajoute une page de repli hors ligne et améliore la gestion du cache.

🎨 style(about.twig): Supprime la mention du photographe (déplacé dans la page d'accueil).
This commit is contained in:
Serreau Jovann
2025-11-17 08:46:52 +01:00
parent 98a487ccad
commit 67a05e8213
3 changed files with 38 additions and 3 deletions

Binary file not shown.

View File

@@ -1,18 +1,54 @@
// This is the "Offline copy of pages" service worker
// This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
const CACHE = "pwabuilder-offline";
const CACHE = "pwabuilder-offline-page";
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
// TODO: replace the following with the correct offline fallback page i.e.: const offlineFallbackPage = "offline.html";
const offlineFallbackPage = "offline.html";
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
});
self.addEventListener('install', async (event) => {
event.waitUntil(
caches.open(CACHE)
.then((cache) => cache.add(offlineFallbackPage))
);
});
if (workbox.navigationPreload.isSupported()) {
workbox.navigationPreload.enable();
}
workbox.routing.registerRoute(
new RegExp('/*'),
new workbox.strategies.StaleWhileRevalidate({
cacheName: CACHE
})
);
self.addEventListener('fetch', (event) => {
if (event.request.mode === 'navigate') {
event.respondWith((async () => {
try {
const preloadResp = await event.preloadResponse;
if (preloadResp) {
return preloadResp;
}
const networkResp = await fetch(event.request);
return networkResp;
} catch (error) {
const cache = await caches.open(CACHE);
const cachedResp = await cache.match(offlineFallbackPage);
return cachedResp;
}
})());
}
});

View File

@@ -169,7 +169,6 @@
<h3 class="text-xl font-bold text-blue-800">ShokoCosplay</h3>
<p class="text-teal-600 font-semibold mb-2">{{'about_founder_shoko_role'|trans}}</p>
<p class="text-sm text-gray-700 mb-2">{{'about_email_label'|trans}}: <a href="mailto:shoko-cosplay@e-cosplay.fr" class="text-blue-600 hover:underline">shoko-cosplay@e-cosplay.fr</a></p>
<div class="text-sm text-gray-600 mb-2">{{'about_photographer_label'|trans}}: dystopix_photography</div>
<div class="social-icons" style="justify-content: center">
<a href="https://www.instagram.com/cosplay_shoko/" target="_blank" aria-label="{{'about_shoko_instagram_aria'|trans}}"><i class="fab fa-instagram fa-lg"></i></a>
<a href="https://www.tiktok.com/@cosshoko?lang=fr" target="_blank" aria-label="{{'about_shoko_tiktok_aria'|trans}}"><i class="fab fa-tiktok fa-lg"></i></a>