add PWA support
This commit is contained in:
@@ -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",
|
||||
|
||||
19
src/scripts/service-worker.js
Normal file
19
src/scripts/service-worker.js
Normal 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);
|
||||
})
|
||||
);
|
||||
});
|
||||
@@ -1,3 +1,16 @@
|
||||
<footer>
|
||||
<p>© {{{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}}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user