Skip to content

armgit / bygga

Public Imported from GitHub
0

IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.

TypeScript

Count visits with Plausible too, served through our own domain

Hassan El Mghari492ce0d240cb
diff --git a/next.config.ts b/next.config.ts
index 6dbfb65..37e0c53 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -1,7 +1,8 @@
import type { NextConfig } from "next";
/*
- * Everything the site loads comes from itself: scripts, fonts (next/font), the voice clips and analytics.
+ * Everything the site loads comes from itself: scripts, fonts (next/font), the voice clips and analytics
+ * (Plausible is proxied under /pl, see the rewrites below).
* Inline scripts stay allowed because the pages are prerendered and can't carry a per-request nonce.
*/
const CSP = [
@@ -81,6 +82,13 @@ const nextConfig: NextConfig = {
},
];
},
+ async rewrites() {
+ // Plausible's script and its event endpoint, served from our own domain
+ return [
+ { source: "/pl/script.js", destination: "https://plausible.io/js/script.js" },
+ { source: "/pl/event", destination: "https://plausible.io/api/event" },
+ ];
+ },
async redirects() {
// the manual scanner is parked for v2: old links land on the search instead
return process.env.NEXT_PUBLIC_SCAN === "1" ? [] : [{ source: "/scan", destination: "/", permanent: false }];
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index d2b711d..321abb2 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -1,5 +1,6 @@
import { Suspense } from "react";
import type { Metadata, Viewport } from "next";
+import Script from "next/script";
import { Noto_Sans, Noto_Sans_Display } from "next/font/google";
import "./globals.css";
import "./guide.css";
@@ -47,6 +48,8 @@ export default function RootLayout({ children }: Readonly<{ children: React.Reac
<body>
{children}
<Analytics />
+ {/* Plausible, served through our own domain (see the rewrites in next.config.ts) so the CSP stays self-only */}
+ <Script src="/pl/script.js" data-domain="usebygga.com" data-api="/pl/event" strategy="afterInteractive" />
{/* it reads the path, which the prerendered shell doesn't know yet */}
<Suspense fallback={null}>
<Offline />
diff --git a/src/app/privacy/page.tsx b/src/app/privacy/page.tsx
index dbd65fe..7bca055 100644
--- a/src/app/privacy/page.tsx
+++ b/src/app/privacy/page.tsx
@@ -51,6 +51,13 @@ export default function Privacy() {
</a>
.
</li>
+ <li>
+ <b>Plausible</b> (European Union) also counts visits without cookies or personal data: the page, the referring site, your country and your browser. See their{" "}
+ <a href="https://plausible.io/data-policy" target="_blank" rel="noreferrer">
+ data policy
+ </a>
+ .
+ </li>
</ul>
<h2>Terms of use</h2>