Cotton code
16 lines · 867 B · TypeScriptRaw
/** * The one address the site shows people to write to, read from site.json so it changes with one edit * (owner, 23 Nov 2026: mukesh@tinfactory.co for now, in place of hello@cottondb.com). Pages and copy name it as * {{contact}} in content/*.html, or CONTACT in code. */import { readFileSync } from "node:fs";import path from "node:path";import { fileURLToPath } from "node:url";const SITE_JSON = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../site.json");export const CONTACT: string = (JSON.parse(readFileSync(SITE_JSON, "utf8")) as { contact: string }).contact;if (!/^[^@\s]+@[^@\s]+\.[a-z]{2,}$/.test(CONTACT)) throw new Error(`site.json: contact is not an email address: ${CONTACT}`);/** The address in place of each {{contact}}. */export const withContact = (html: string): string => html.replaceAll("{{contact}}", CONTACT);