add PWA support

This commit is contained in:
2024-01-17 18:23:17 +01:00
parent 1f6eeadfa4
commit 7ca68eab48
8 changed files with 79 additions and 7 deletions

View File

@@ -1,11 +1,14 @@
{
"theme": "galaxy",
"enablePWA": true,
"head": {
"title": "LinkMeUp WieErWill",
"short_title": "WieErWill",
"description": "Get all weblinks of WieErWill.",
"keywords": "social media links, software architecture, web development, single-page application, web performance",
"url": "https://link.wieerwill.de/",
"logo": "favicons/android-chrome-192x192.png"
"logo": "android-chrome-192x192.png",
"themecolor": "#0078D4"
},
"header": {
"title": "WieErWill",

View File

@@ -0,0 +1,19 @@
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open('linkemeup').then((cache) => {
return cache.addAll([
'/',
'/index.html',
/* Add other URLs of assets to cache */
]);
})
);
});
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request).then((response) => {
return response || fetch(event.request);
})
);
});

View File

@@ -1,3 +1,16 @@
<footer>
<p>&copy; {{{footer.copyright}}} {{currentYear}}</p>
</footer>
</footer>
{{#if enablePWA}}
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then((registration) => {
console.log('Service Worker registered with scope:', registration.scope);
})
.catch((error) => {
console.error('Service Worker registration failed:', error);
});
}
</script>
{{/if}}

View File

@@ -18,8 +18,10 @@
<title>LinkMeUp WieErWill</title>
<meta name="description" content="{{head.description}}">
<meta name="keywords" content="{{head.keywords}}">
<meta name="theme-color" content="{{head.themecolor}}">
<link rel="canonical" href="{{head.url}}">
<meta property="og:title" content="{{head.title}}">
<meta property="og:description" content="{{head.description}}">
<meta property="og:image" content="{{head.url}}{{head.logo}}">
<link rel="manifest" href="/manifest.json">
</head>