Google analytics integration.

Sentry.io integration.
Vince integration.
Region-scoped consent (denied-by-default in EU/EEA/UK/CH, granted elsewhere, DPDP-friendly notice)
This commit is contained in:
2026-09-06 16:03:13 +00:00
parent 43c6fbe437
commit e0eb577e3e
37 changed files with 2059 additions and 274 deletions
+74
View File
@@ -0,0 +1,74 @@
/**
* Generates dist/client/sitemap.xml after `vite build`.
*
* Static routes are listed explicitly; journal essay slugs are parsed from
* src/data/catalog.ts so they stay in sync with the source of truth.
* Dynamic product/collection pages are intentionally excluded for now —
* they duplicate shop.mozimo.in content and churn constantly.
*
* Origin: SITE_ORIGIN env (default https://mozimo.in).
*/
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
const origin = (process.env.SITE_ORIGIN ?? "https://mozimo.in").replace(
/\/+$/,
"",
);
const STATIC_ROUTES = [
{ path: "/", priority: 1.0, changefreq: "weekly" },
{ path: "/chocolate", priority: 0.9, changefreq: "weekly" },
{ path: "/gifting", priority: 0.9, changefreq: "weekly" },
{ path: "/experiences", priority: 0.7, changefreq: "monthly" },
{ path: "/bespoke", priority: 0.8, changefreq: "monthly" },
{ path: "/contact", priority: 0.5, changefreq: "yearly" },
{ path: "/our-world", priority: 0.6, changefreq: "monthly" },
{ path: "/journal", priority: 0.6, changefreq: "monthly" },
{ path: "/privacy", priority: 0.2, changefreq: "yearly" },
];
// journal essay slugs live in src/data/catalog.ts (the essays block)
const catalogSrc = readFileSync(join(root, "src/data/catalog.ts"), "utf8");
const slugs = [...catalogSrc.matchAll(/^\s{4}slug:\s*"([^"]+)"/gm)].map(
(m) => m[1],
);
const today = new Date().toISOString().slice(0, 10);
const urls = [
...STATIC_ROUTES,
...slugs.map((slug) => ({
path: `/journal/${slug}`,
priority: 0.5,
changefreq: "yearly",
})),
];
const xml = [
'<?xml version="1.0" encoding="UTF-8"?>',
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
...urls.map(({ path, priority, changefreq }) =>
[
" <url>",
` <loc>${origin}${path === "/" ? "/" : path}</loc>`,
` <lastmod>${today}</lastmod>`,
changefreq ? ` <changefreq>${changefreq}</changefreq>` : null,
priority !== undefined ? ` <priority>${priority}</priority>` : null,
" </url>",
]
.filter(Boolean)
.join("\n"),
),
"</urlset>",
"",
].join("\n");
const outDir = join(root, "dist/client");
mkdirSync(outDir, { recursive: true });
writeFileSync(join(outDir, "sitemap.xml"), xml, "utf8");
console.log(
`[sitemap] ${urls.length} URLs → dist/client/sitemap.xml (origin ${origin})`,
);