Skip to content

Adding automatically generated & pushed FAQ JSON-LD schema feature to accordion - #199

Draft
JonBarakMierke wants to merge 3 commits into
sheafui:masterfrom
JonBarakMierke:feat/faq_on_accordion
Draft

Adding automatically generated & pushed FAQ JSON-LD schema feature to accordion#199
JonBarakMierke wants to merge 3 commits into
sheafui:masterfrom
JonBarakMierke:feat/faq_on_accordion

Conversation

@JonBarakMierke

Copy link
Copy Markdown

Summary

Adds a faq boolean attribute to <x-ui.accordion>.
When present, the component parses its rendered items and automatically builds a FAQPage JSON-LD schema, then pushes it onto Laravel's head stack via @Push('head').

Each accordion item's trigger text becomes a Question, and its content panel's markup becomes the corresponding Answer.
Items with an empty trigger or empty content are silently skipped rather than emitted as blank entries.

No new dependencies — extraction uses PHP's built-in DOMDocument/DOMXPath, consistent with the library's zero-dependency, copy-paste philosophy.
</ sequences in answer HTML are escaped to prevent breaking out of the <script> tag.

Usage

<x-ui.accordion faq>
    <x-ui.accordion.item trigger="What is your return policy?">
        <p>We offer a 30-day return policy for all unused items in their original packaging.</p>
    </x-ui.accordion.item>
    <x-ui.accordion.item trigger="How long does shipping take?">
        <p>Standard shipping typically takes 3-5 business days.</p>
    </x-ui.accordion.item>
</x-ui.accordion>

Consumers need @stack('head') declared in their layout's for the schema to be emitted — this is documented in usage.md

@JonBarakMierke
JonBarakMierke marked this pull request as draft August 17, 2026 21:45
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.

1 participant