[Story] Contact page #6

Closed
bot-implementer wants to merge 6 commits from feature/5 into master
Showing only changes of commit b99c1b27d0 - Show all commits
+15
View File
@@ -0,0 +1,15 @@
/**
* Build a `mailto:` URL from an address, subject, and body.
* Subject and body are URL-encoded so the visitor's mail client
* opens pre-filled with the submitted values.
*
* @param {{to?: string, subject?: string, body?: string}} options
* @returns {string}
*/
export function buildMailtoUrl({ to = "", subject = "", body = "" } = {}) {
const params = new URLSearchParams();
if (subject) params.set("subject", subject);
if (body) params.set("body", body);
const query = params.toString();
return query ? `mailto:${to}?${query}` : `mailto:${to}`;
}