diff --git a/.env.example b/.env.example index 38f90cb6..af4fdd97 100644 --- a/.env.example +++ b/.env.example @@ -1,11 +1,10 @@ -# Hosted form endpoint used by the contact form. -# Examples: Formspree, Basin, Getform, or a self-hosted POST endpoint. +# Optional override for the hosted contact-form endpoint configured in src/config/contact.ts. PUBLIC_CONTACT_FORM_ENDPOINT= # Optional comma-separated fallback recipients used by the mailto fallback. PUBLIC_CONTACT_RECIPIENTS=directors@familyfed.ie,info@familyfed.ie,media@familyfed.ie -# Optional admin URL for reviewing stored contact form submissions. +# Optional override for the submissions URL configured in src/config/contact.ts. PUBLIC_CONTACT_SUBMISSIONS_URL= # Optional Plausible analytics configuration. diff --git a/docs/ADMIN.md b/docs/ADMIN.md index b871b7a6..fbee8d89 100644 --- a/docs/ADMIN.md +++ b/docs/ADMIN.md @@ -26,14 +26,15 @@ repository and deploy as usual. ## Contact form -Set `PUBLIC_CONTACT_FORM_ENDPOINT` during the build to make the contact form -send real submissions through a hosted form provider such as Formspree, Basin, -Getform, or a self-hosted endpoint. +The default hosted form endpoint and submissions inbox are configured in +`src/config/contact.ts`. The deployed form sends submissions through Formspree. +Set `PUBLIC_CONTACT_FORM_ENDPOINT` during the build only when overriding the +committed endpoint with another Formspree form or hosted provider. Optional variables: - `PUBLIC_CONTACT_RECIPIENTS`: comma-separated mail fallback recipients. -- `PUBLIC_CONTACT_SUBMISSIONS_URL`: admin dashboard URL for form submissions. +- `PUBLIC_CONTACT_SUBMISSIONS_URL`: override for the admin submissions-inbox URL. If no endpoint is configured, the form falls back to opening the visitor's email application with the message filled in. diff --git a/src/config/contact.ts b/src/config/contact.ts new file mode 100644 index 00000000..d4293bf6 --- /dev/null +++ b/src/config/contact.ts @@ -0,0 +1,3 @@ +export const defaultContactFormEndpoint = "https://formspree.io/f/mjgqnrvj"; +export const defaultContactSubmissionsUrl = "https://formspree.io/forms/mjgqnrvj/submissions"; +export const defaultContactRecipients = "directors@familyfed.ie,info@familyfed.ie,media@familyfed.ie"; diff --git a/src/pages/admin/index.astro b/src/pages/admin/index.astro index 5b221548..ede0ca22 100644 --- a/src/pages/admin/index.astro +++ b/src/pages/admin/index.astro @@ -1,13 +1,14 @@ --- import { getArchiveEntries } from "../../lib/archive"; import { speechAdminEntryFromArchiveEntry } from "../../lib/admin-speeches"; +import { defaultContactFormEndpoint, defaultContactSubmissionsUrl } from "../../config/contact"; import { calendarEvents, recurringCalendarEvents } from "../../data/events"; const entries = await getArchiveEntries(); const blogEntries = entries.filter((entry) => entry.data.type === "blog"); const speechEntries = entries.filter((entry) => entry.data.type === "speech"); -const contactFormEndpoint = import.meta.env.PUBLIC_CONTACT_FORM_ENDPOINT ?? ""; -const contactSubmissionsUrl = import.meta.env.PUBLIC_CONTACT_SUBMISSIONS_URL ?? ""; +const contactFormEndpoint = import.meta.env.PUBLIC_CONTACT_FORM_ENDPOINT || defaultContactFormEndpoint; +const contactSubmissionsUrl = import.meta.env.PUBLIC_CONTACT_SUBMISSIONS_URL || defaultContactSubmissionsUrl; const analyticsDashboardUrl = import.meta.env.PUBLIC_ANALYTICS_DASHBOARD_URL ?? ""; const plausibleDomain = import.meta.env.PUBLIC_PLAUSIBLE_DOMAIN ?? ""; const today = new Date().toISOString().slice(0, 10); diff --git a/src/pages/contact.astro b/src/pages/contact.astro index 79d8b342..afbeb0ce 100644 --- a/src/pages/contact.astro +++ b/src/pages/contact.astro @@ -1,10 +1,11 @@ --- import SiteLayout from "../components/SiteLayout.astro"; import TwoColumnPage from "../components/TwoColumnPage.astro"; +import { defaultContactFormEndpoint, defaultContactRecipients } from "../config/contact"; import articleHtml from "../content/pages/contact.html?raw"; -const contactFormEndpoint = import.meta.env.PUBLIC_CONTACT_FORM_ENDPOINT ?? ""; -const contactRecipients = import.meta.env.PUBLIC_CONTACT_RECIPIENTS ?? "directors@familyfed.ie,info@familyfed.ie,media@familyfed.ie"; +const contactFormEndpoint = import.meta.env.PUBLIC_CONTACT_FORM_ENDPOINT || defaultContactFormEndpoint; +const contactRecipients = import.meta.env.PUBLIC_CONTACT_RECIPIENTS || defaultContactRecipients; const contactFormAction = contactFormEndpoint || `mailto:${contactRecipients}`; const contactFormConfig = JSON.stringify({ endpoint: contactFormEndpoint,