Conversation
Deploying head-start with
|
| Latest commit: |
56e410d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://baceb638.head-start.pages.dev |
| Branch Preview URL: | https://feat-forms.head-start.pages.dev |
…urnstile on form back button
…00 and 500 errors in different if behaviours
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a CMS-driven “Form” capability to Head Start: a new Form component + FormBlock, a DatoCMS schema/migration for form definitions, and an API route that validates submissions (with Cloudflare Turnstile support).
Changes:
- Adds a new
Formscontent collection (DatoCMS GraphQL + Astro content loader) and aFormBlockto render a referenced form by slug. - Adds server-side form validation + per-form action handlers under
/api/forms/[slug]/. - Adds Turnstile integration and client-side progressive enhancement for inline error rendering.
Reviewed changes
Copilot reviewed 38 out of 39 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pages/api/forms/[slug]/index.ts | New POST endpoint for form validation + dispatch to per-form action module |
| src/pages/api/forms/[slug]/_contact.ts | Example form action handler returning a success view |
| src/pages/[locale]/_index.query.graphql | Adds FormBlock fragment inclusion on home page query |
| src/lib/renderer/index.ts | Import order tweak + adds renderToResponse helper |
| src/lib/forms/validate.ts | Implements server-side validation + Turnstile gating |
| src/lib/forms/turnstile.ts | Implements Turnstile /siteverify call |
| src/lib/forms/index.ts | Exposes form helpers from src/lib/forms/* |
| src/content/Pages/CollectionEntry.query.graphql | Adds FormBlock fragment inclusion for pages |
| src/content/PagePartials/CollectionEntry.query.graphql | Adds FormBlock fragment inclusion for page partials |
| src/content/Forms/index.ts | New Astro content collection loader for Forms |
| src/content/Forms/CollectionEntry.query.graphql | GraphQL query for a single Form record |
| src/content/config.ts | Registers the new Forms collection |
| src/components/FormField/FormField.astro | Renders individual fields and groups (fieldset for checkbox/radio) |
| src/components/FormField/fieldTypes.ts | Defines supported field types and a type guard |
| src/components/FormField/Fields/Textarea.astro | Textarea field component |
| src/components/FormField/Fields/Select.astro | Select field component |
| src/components/FormField/Fields/RadioGroup.astro | Radio group renderer |
| src/components/FormField/Fields/Input.astro | Input field component |
| src/components/FormField/Fields/Fieldset.astro | Wrapper for checkbox/radio groups |
| src/components/FormField/Fields/CheckboxGroup.client.ts | Web component to enforce “at least one required” for checkbox groups |
| src/components/FormField/Fields/CheckboxGroup.astro | Checkbox group renderer + client script include |
| src/components/Form/Turnstile.astro | Turnstile widget markup injection |
| src/components/Form/index.ts | Component barrel exports for Form views |
| src/components/Form/FormSuccess.astro | Success view |
| src/components/Form/FormNotFound.astro | Not-found view |
| src/components/Form/FormError.astro | Error view |
| src/components/Form/Form.test.ts | Unit tests for Form rendering + API behavior |
| src/components/Form/Form.astro | Form renderer (fields + submit + Turnstile + error template) |
| src/blocks/FormBlock/README.md | Documentation for the new FormBlock |
| src/blocks/FormBlock/FormBlock.fragment.graphql | GraphQL fragment for the FormBlock |
| src/blocks/FormBlock/FormBlock.astro | Block implementation resolving Form entry and rendering <web-form> |
| src/blocks/FormBlock/Form.client.ts | Client-side enhancement: AJAX submit + inline errors + Turnstile gating |
| src/blocks/blocksByTypename.ts | Registers FormBlockRecord mapping |
| env.d.ts | Adds Turnstile env vars typing |
| datocms-environment.ts | Changes the configured DatoCMS environment |
| config/datocms/migrations/1780562401_featForms.ts | Migration adding Form models/blocks and wiring them into page body blocks |
| astro.config.ts | Adds Turnstile env schema entries |
| .github/workflows/node-ci.yml | Adds Turnstile env vars to CI environment |
| .env.example | Adds Turnstile env var placeholders |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @see docs/decision-log/2023-10-24-datocms-env-file.md on why file is preferred over env vars | ||
| */ | ||
| export const datocmsEnvironment = 'deploy-search-form'; | ||
| export const datocmsEnvironment = 'dev-sandbox-21-05'; |
turnstile token to string, removes use turnstile input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Large parts are copied from projects by @jurgenbelien and @velomovies
Changes
text,email,phone,number,date,textarea,select,radio,checkboxAssociated issue
#113
How to test
Checklist
I have added a decision log entry if the change affects the architecture or changes a significant technology