Skip to content

feat(tools): add DA plugin to generate FAQPage JSON-LD - #487

Draft
sdmcraft wants to merge 3 commits into
mainfrom
feat/da-json-ld-schema-plugin
Draft

feat(tools): add DA plugin to generate FAQPage JSON-LD#487
sdmcraft wants to merge 3 commits into
mainfrom
feat/da-json-ld-schema-plugin

Conversation

@sdmcraft

Copy link
Copy Markdown
Contributor

Summary

Adds a DA library plugin (tools/plugins/json-ld-schema/) that reads a page's .faq block content and generates FAQPage JSON-LD for the author to copy to clipboard and paste into the page's json-ld metadata row.

Grew out of the manual FAQPage JSON-LD work done across #451/#484/#485 — this makes that workflow self-serve instead of requiring an engineer to hand-generate it per page. Full plan, decisions, and prior-art review logged in #486.

  • Extracts Q&A from any .faq-classed block (variant classes like faq cmp included), de-duplicating exact repeats and flattening multi-paragraph/list answers with word-boundary-safe joins (avoids the "answers run together" bug hit in a previous code-level attempt, PR feat(seo): add dynamic JSON-LD (BreadcrumbList + FAQPage) #472).
  • Merges the generated FAQPage node into any existing json-ld metadata @graph by @type — verified idempotent (re-running doesn't duplicate nodes).
  • Resolves the @id in order: existing WebPage node in the page's own json-ld → a plain canonical/url metadata key → the current aem.page URL.
  • Copy-to-clipboard only — no write-back to the document. A direct-PUT approach via the DA Source API was considered and dropped: it isn't a Y.js delta and can conflict with an open live-editing session. Reading the source is safe; writing it isn't, so insertion happens through the normal DA editor instead.

Reuses parseMetadata(), buildSourceUrl(), buildPageUrl(), and pick() from an external reference plugin (usman-khalid/da-playground/tools/json-ld-generator); FAQ extraction and @graph merge logic are new, ported from the Python script used to fix #451/#484.

Verification

Test plan

  • Register in DA library config sheet (title: JSON-LD Schema, path: /tools/plugins/json-ld-schema/json-ld-schema.html, experience: dialog) — needs a DA org admin
  • Open a page with a .faq block in the DA editor, launch the plugin from the Library panel, confirm the preview UI renders
  • Confirm "Copy to clipboard" works and pasted value is valid JSON
  • Confirm re-running on a page that already has json-ld merges rather than duplicates

Closes #486

Reads a page's .faq block content, merges a FAQPage node into the
page's existing json-ld metadata @graph (idempotent by @type), and
offers copy-to-clipboard for the author to paste into the Metadata
block themselves -- no direct write-back to the document, avoiding
any conflict with an open live-editing session.

Fixes #486
@aem-code-sync

aem-code-sync Bot commented Aug 16, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run all PSI checks
  • Re-run failed PSI checks
  • Re-sync branch
Commits

A literal null byte had ended up in the template literal on the
dedup key line, making git/GitHub treat the file as binary
("Binary file not shown" in the PR diff). Replaced with a space;
no functional change, re-verified extraction still works.
Reference implementation to port from for the plugin's planned
BreadcrumbList extractor module (see #486 discussion): depth-by-page-type
rules, label derivation (title-segment + slug fallback), dead-link-crumb
avoidance for pseudo-category pages, and merge-by-@type behavior. Ported
from the batch/Node version to run against a local content/ clone; the
plugin's browser/DA-Source-API context will need its own I/O layer around
the same extraction logic.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant