SEO and PWA

This commit is contained in:
sakrecoer 2020-08-05 15:54:25 +02:00
parent 233b264e0f
commit ec5f87cbeb
22 changed files with 169 additions and 6 deletions

View file

@ -16,6 +16,46 @@
<link rel="icon" type="image/png" href="{{ site.url }}/touch-icon.png" sizes="192x192">
<link rel="shortcut icon" href="{{ site.url }}{{ site.icon }}" type="image/png" />
<noscript><link rel="stylesheet" href="{{ relBase }}/assets/css/noscripts-20200805.css" /></noscript>
<link rel="manifest" href="manifest.json" />
<meta name="theme-color" content="{{ site.bg }}"/>
<script type="text/javascript">
// Registration of service worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register("/service-worker.js").then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
});
}
else{
console.log('Service Workers not supported');
}
// Installation of service worker
self.addEventListener('install', function(event) {
// Perform install steps
event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache) {
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request, {ignoreSearch:true}).then(response => {
return response || fetch(event.request);
})
);
});
</script>
</head>
<body>
@ -37,5 +77,7 @@
{% endunless %}
{% include cookie-consent.html %}
{% include scripts.html %}
</body>
</html>
</html>