Skip to content

Commit 8ecfeb5

Browse files
committed
Update app
1 parent a54c337 commit 8ecfeb5

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

astro.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ export default defineConfig({
122122
svelte(),
123123
serviceWorker({
124124
workbox: { inlineWorkboxRuntime: true },
125-
enableInDevelopment: true,
126125
}),
127126
compress({
128127
HTML: false,

src/components/Offline.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</div>
77
<script is:inline>
88

9-
document.addEventListener('astro:page-load', () => {
9+
document.addEventListener('DOMContentLoaded', () => {
1010
const offlineIcon = document.getElementById('offline-icon');
1111

1212
function updateOnlineStatus() {
@@ -17,7 +17,6 @@
1717
window.addEventListener('online', updateOnlineStatus);
1818
window.addEventListener('offline', updateOnlineStatus);
1919

20-
// Initial check
2120
updateOnlineStatus();
2221
}
2322
);

src/layouts/Layout.astro

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,27 @@ if ("serviceWorker" in navigator) {
117117
});
118118
});
119119
}
120+
121+
if (window.matchMedia('(display-mode: standalone)').matches) {
122+
document.addEventListener('click', function (e: any) {
123+
const anchor = e.target.closest('a');
124+
125+
if (!anchor || !anchor.href) return;
126+
127+
const origin = window.location.origin;
128+
const href = anchor.getAttribute('href');
129+
130+
if (
131+
href.startsWith('#') ||
132+
href.startsWith('/') ||
133+
href.startsWith(origin)
134+
) {
135+
return;
136+
}
137+
138+
e.preventDefault();
139+
140+
alert('External links are available only via website.');
141+
});
142+
}
120143
</script>

0 commit comments

Comments
 (0)