seo improvement and updated notifs
This commit is contained in:
40
public/firebase-messaging-sw.js
Normal file
40
public/firebase-messaging-sw.js
Normal file
@@ -0,0 +1,40 @@
|
||||
// Firebase Cloud Messaging service worker
|
||||
// Config values are injected at build time by the Vite plugin (see vite.config.ts)
|
||||
importScripts('https://www.gstatic.com/firebasejs/10.12.0/firebase-app-compat.js')
|
||||
importScripts('https://www.gstatic.com/firebasejs/10.12.0/firebase-messaging-compat.js')
|
||||
|
||||
firebase.initializeApp({
|
||||
apiKey: '__VITE_FIREBASE_API_KEY__',
|
||||
authDomain: '__VITE_FIREBASE_AUTH_DOMAIN__',
|
||||
projectId: '__VITE_FIREBASE_PROJECT_ID__',
|
||||
messagingSenderId: '__VITE_FIREBASE_MESSAGING_SENDER_ID__',
|
||||
appId: '__VITE_FIREBASE_APP_ID__',
|
||||
})
|
||||
|
||||
const messaging = firebase.messaging()
|
||||
|
||||
// Handle background push messages (browser/PWA is closed or in background)
|
||||
messaging.onBackgroundMessage((payload) => {
|
||||
const title = payload.notification?.title || 'Grateful Journal 🌱'
|
||||
const body = payload.notification?.body || "You haven't written today yet. Take a moment to reflect."
|
||||
|
||||
self.registration.showNotification(title, {
|
||||
body,
|
||||
icon: '/web-app-manifest-192x192.png',
|
||||
badge: '/favicon-96x96.png',
|
||||
tag: 'gj-daily-reminder',
|
||||
})
|
||||
})
|
||||
|
||||
self.addEventListener('notificationclick', (e) => {
|
||||
e.notification.close()
|
||||
e.waitUntil(
|
||||
self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clients) => {
|
||||
if (clients.length > 0) {
|
||||
clients[0].focus()
|
||||
return clients[0].navigate('/')
|
||||
}
|
||||
return self.clients.openWindow('/')
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -1,6 +1,4 @@
|
||||
User-agent: *
|
||||
Disallow: /write
|
||||
Disallow: /history
|
||||
Disallow: /settings
|
||||
Disallow:
|
||||
|
||||
Sitemap: https://gratefuljournal.online/sitemap.xml
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://gratefuljournal.online/</loc>
|
||||
<lastmod>2026-04-08</lastmod>
|
||||
<lastmod>2026-04-13</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://gratefuljournal.online/about</loc>
|
||||
<lastmod>2026-04-08</lastmod>
|
||||
<lastmod>2026-04-13</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.7</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://gratefuljournal.online/privacy</loc>
|
||||
<lastmod>2026-04-08</lastmod>
|
||||
<lastmod>2026-04-13</lastmod>
|
||||
<changefreq>yearly</changefreq>
|
||||
<priority>0.4</priority>
|
||||
</url>
|
||||
|
||||
15
public/sw.js
15
public/sw.js
@@ -18,6 +18,21 @@ self.addEventListener('activate', (e) => {
|
||||
self.clients.claim()
|
||||
})
|
||||
|
||||
self.addEventListener('notificationclick', (e) => {
|
||||
e.notification.close()
|
||||
e.waitUntil(
|
||||
self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clients) => {
|
||||
if (clients.length > 0) {
|
||||
const client = clients[0]
|
||||
client.focus()
|
||||
client.navigate('/')
|
||||
} else {
|
||||
self.clients.openWindow('/')
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
self.addEventListener('fetch', (e) => {
|
||||
// Only cache GET requests for same-origin non-API resources
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user