pwa - the SIMPLIEST fix

This commit is contained in:
Piotr Domański 2026-04-03 22:46:55 +02:00
parent 9bbc8cd0b3
commit 578e8089c7

View file

@ -10,6 +10,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Fooder" /> <meta name="apple-mobile-web-app-title" content="Fooder" />
<link rel="apple-touch-icon" href="%sveltekit.assets%/icons/apple-touch-icon-180x180.png" /> <link rel="apple-touch-icon" href="%sveltekit.assets%/icons/apple-touch-icon-180x180.png" />
<link rel="manifest" href="%sveltekit.assets%/manifest.json" />
<!-- Android PWA --> <!-- Android PWA -->
<meta name="mobile-web-app-capable" content="yes" /> <meta name="mobile-web-app-capable" content="yes" />
@ -19,33 +20,6 @@
<title>Fooder</title> <title>Fooder</title>
%sveltekit.head% %sveltekit.head%
<script>
// iOS PWA: intercept internal <a> clicks in capture phase so Safari never
// processes them as "real" navigations (which causes the browser chrome to appear).
if (window.navigator.standalone) {
document.addEventListener('click', function (e) {
var node = e.target;
while (node) {
if (node.nodeName === 'A' && node.href) {
try {
var url = new URL(node.href);
if (
url.origin === window.location.origin &&
!node.download &&
node.target !== '_blank'
) {
e.preventDefault();
history.pushState(null, '', url.pathname + url.search + url.hash);
window.dispatchEvent(new PopStateEvent('popstate', { state: null }));
}
} catch (_) {}
break;
}
node = node.parentElement;
}
}, true);
}
</script>
</head> </head>
<body data-sveltekit-preload-data="hover" class="bg-zinc-950 text-zinc-100 antialiased"> <body data-sveltekit-preload-data="hover" class="bg-zinc-950 text-zinc-100 antialiased">
<div style="display: contents">%sveltekit.body%</div> <div style="display: contents">%sveltekit.body%</div>