issue with notch
This commit is contained in:
@@ -13,6 +13,8 @@ const cfg = getPublicConfig();
|
||||
|
||||
const siteUrl = (cfg.siteUrl || "http://localhost:4321").replace(/\/$/, "");
|
||||
const canonicalUrl = `${siteUrl}${canonicalPath.startsWith("/") ? canonicalPath : `/${canonicalPath}`}`;
|
||||
|
||||
const assetSuffix = cfg.assetVersion ? `?v=${encodeURIComponent(cfg.assetVersion)}` : "";
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
@@ -48,7 +50,7 @@ const canonicalUrl = `${siteUrl}${canonicalPath.startsWith("/") ? canonicalPath
|
||||
rel="stylesheet"
|
||||
/>
|
||||
|
||||
<link rel="stylesheet" href="/styles/global.css" />
|
||||
<link rel="stylesheet" href={`/styles/global.css${assetSuffix}`} />
|
||||
|
||||
<script is:inline>
|
||||
(() => {
|
||||
@@ -117,12 +119,13 @@ const canonicalUrl = `${siteUrl}${canonicalPath.startsWith("/") ? canonicalPath
|
||||
// Register SW only in production builds (Astro sets import.meta.env.PROD at build time).
|
||||
// Allow opting out via PUBLIC_ENABLE_SW="false".
|
||||
import.meta.env.PROD && import.meta.env.PUBLIC_ENABLE_SW !== "false" ? (
|
||||
<script is:inline>
|
||||
<script is:inline define:vars={{ assetSuffix }}>
|
||||
if ("serviceWorker" in navigator) {
|
||||
// SW requires HTTPS (or localhost). In prod we expect HTTPS.
|
||||
window.addEventListener("load", () => {
|
||||
const swUrl = "/sw.js" + assetSuffix;
|
||||
navigator.serviceWorker
|
||||
.register("/sw.js", { scope: "/", updateViaCache: "none" })
|
||||
.register(swUrl, { scope: "/", updateViaCache: "none" })
|
||||
.catch((err) => {
|
||||
// Progressive enhancement; keep failures non-fatal.
|
||||
console.warn("Service worker registration failed", err);
|
||||
|
||||
Reference in New Issue
Block a user