Skip to content

Structured FAQ block using accordion items - #483

Open
JopMolenaar wants to merge 5 commits into
mainfrom
feat/structured-faq-block
Open

Structured FAQ block using accordion items#483
JopMolenaar wants to merge 5 commits into
mainfrom
feat/structured-faq-block

Conversation

@JopMolenaar

Copy link
Copy Markdown
Contributor

Changes

  • Adds FAQ collection model where content creators can add records (questions) using an accordion item and a slug.
  • Adds FAQ block which links to records added to the FAQ collection
  • Copied from de voorhoede website: has item linking
  • Doesn't have a open first item boolean like the accordion block has.
  • Does have deep linking when you target a question, using the slug of the record.

Associated issue

Resolves #482

How to test

  • Add a demo page using the faq block, and check if everything works as expected
  • Try targeting a question in the url and make sure it jumps in the screen and opens the answer.

Checklist

  • I have performed a self-review of my own code
  • I have made sure that my PR is easy to review (not too big, includes comments)
  • I have made updated relevant documentation files (in project README, docs/, etc)
  • I have added a decision log entry if the change affects the architecture or changes a significant technology
  • I have notified a reviewer

@JopMolenaar JopMolenaar self-assigned this Jul 24, 2026
Copilot AI review requested due to automatic review settings July 24, 2026 15:08
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
head-start a3e5b98 Commit Preview URL

Branch Preview URL
Jul 29 2026, 09:18 AM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a reusable “FAQ” content model in DatoCMS and a corresponding FaqBlock that renders selected FAQ records as an accordion, including URL hash deep-linking to open a specific question.

Changes:

  • Introduces FaqBlock (Astro + GraphQL fragment + client script) and registers it in block rendering/type plumbing.
  • Extends page/home GraphQL queries to fetch and render the new FaqBlockRecord.
  • Adds a DatoCMS migration to create the faq collection model + faq_block modular block and allow it in Page/Home body blocks.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/pages/[locale]/_index.query.graphql Includes the new FaqBlock fragment/type in the Home page query.
src/content/Pages/CollectionEntry.query.graphql Includes the new FaqBlock fragment/type in generic Page collection entry query.
src/components/Accordion/AccordionItem.astro Makes name optional and adds id passthrough for <details> (supports deep linking).
src/blocks/FaqBlock/README.md Documents the new block and its DatoCMS model relationship.
src/blocks/FaqBlock/FaqBlock.test.ts Adds unit tests for rendering, grouping title, content, and deep-link IDs.
src/blocks/FaqBlock/FaqBlock.preview.txt Preview text for the block scaffold.
src/blocks/FaqBlock/FaqBlock.fragment.graphql Defines GraphQL fragment to fetch group title + linked FAQ records and their accordion item content.
src/blocks/FaqBlock/FaqBlock.client.ts Implements hash-based open + scroll behavior for targeted questions.
src/blocks/FaqBlock/FaqBlock.astro Renders the FAQ group title and accordion items, wires in the client script.
src/blocks/blocksByTypename.ts Registers FaqBlockRecordFaqBlock.astro mapping.
src/blocks/Blocks.d.ts Extends AnyBlock typing to include FaqBlockFragment.
datocms-environment.ts Updates the configured DatoCMS environment name for this branch.
config/datocms/migrations/1784902160_faqBlock.ts Adds migration creating faq + faq_block and updates Page/Home body block validators.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/blocks/FaqBlock/FaqBlock.astro Outdated
Comment on lines +20 to +21
openTargetedQuestion();
window.addEventListener('hashchange', openTargetedQuestion);
Comment thread src/components/Accordion/AccordionItem.astro Outdated
Comment thread config/datocms/migrations/1784902160_faqBlock.ts Outdated
Comment on lines +13 to +16
{ block.groupTitle && <h2>{ block.groupTitle }</h2> }

<Accordion>
{ faqs.map((faq) => (
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a FAQ block with the proper semantics and structured data, like we have in De Voorhoede website

2 participants