seo improvement and updated notifs

This commit is contained in:
2026-04-13 12:27:30 +05:30
parent df4bb88f70
commit 34254f94f9
26 changed files with 941 additions and 58 deletions

View 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('/')
})
)
})

View File

@@ -1,6 +1,4 @@
User-agent: *
Disallow: /write
Disallow: /history
Disallow: /settings
Disallow:
Sitemap: https://gratefuljournal.online/sitemap.xml

View File

@@ -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>

View File

@@ -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 (