This commit is contained in:
Stefan Lazic committed 2026-08-03 21:15:24 +01:00
1 parent ec5583f972
commit 546613e677
189 files changed
+9873 -655

No files matched your search

@@ -0,0 +1,37 @@
import { escapeHtml } from "./layout";
export interface BusinessEmailInfo {
name: string;
logoUrl?: string;
address?: string;
phone?: string;
cancellationPolicy?: string;
}
/** Absolute URL — email clients can't resolve a relative path, unlike a browser looking at the current origin. */
export function absoluteUrl(path: string): string {
const base = process.env.NEXT_PUBLIC_APP_URL ?? "http://localhost:3000";
return path.startsWith("http") ? path : `${base}${path.startsWith("/") ? "" : "/"}${path}`;
}
export function footerNoteHtml(business: BusinessEmailInfo): string | undefined {
const parts: string[] = [];
if (business.address) parts.push(business.address);
if (business.phone) parts.push(business.phone);
if (business.cancellationPolicy) parts.push(business.cancellationPolicy);
return parts.length > 0 ? parts.map((p) => `<span>${escapeHtml(p)}</span>`).join("<br/>") : undefined;
}
export function footerNoteText(business: BusinessEmailInfo): string | undefined {
const parts: string[] = [];
if (business.address) parts.push(business.address);
if (business.phone) parts.push(business.phone);
if (business.cancellationPolicy) parts.push(business.cancellationPolicy);
return parts.length > 0 ? parts.join("\n") : undefined;
}
export interface RenderedEmail {
subject: string;
html: string;
text: string;
}