import type { SunsetConfig } from "./db"; function esc(s: string): string { return s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]!)); } export function renderSunsetPage(opts: { domain: string; target: string; preservePath: boolean; reqPath: string; cfg: SunsetConfig; }): string { const title = opts.cfg.title || "Diese Domain wird abgeschaltet"; const message = opts.cfg.message || `Die Domain ${opts.domain} wird abgeschaltet. Bitte aktualisiere deine Lesezeichen.`; const button = opts.cfg.button_label || "Weiter"; const date = opts.cfg.sunset_date ? `Geplante Abschaltung: ${opts.cfg.sunset_date}` : ""; // Continue link points back at OUR domain with nr_continue=1 — server.ts then skips the // sunset interstitial and serves the actual redirect. const path = opts.reqPath || "/"; const sep = path.includes("?") ? "&" : "?"; const continueUrl = `${path}${sep}nr_continue=1`; return ` ${esc(title)}

${esc(title)}

${esc(message)}

${date ? `

${esc(date)}

` : ""} ${esc(button)}

${esc(opts.domain)} → ${esc(opts.target)}

`; }