-
Notifications
You must be signed in to change notification settings - Fork 0
feat(adp): citation-bait schema fields + FAQPage emission #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
b15d37f
736c1a8
506d35f
c7f7de8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // --------------------------------------------------------------------------- | ||
| // ExpertQuoteBlock | ||
| // --------------------------------------------------------------------------- | ||
| // Semantic <blockquote> rendering an authoritative external quote with its | ||
| // attribution linked back to a public source. Sits between the diagram and | ||
| // the decision matrix so the satellite reads as: visual model → external | ||
| // validation → go/no-go. | ||
| // | ||
| // Visibility: not wrapped in <DisclosureSection> by design — the quote | ||
| // must render unconditionally for citation lift. | ||
|
|
||
| import type { Pattern } from "@/data/agentic-design-patterns/types"; | ||
|
|
||
| interface ExpertQuoteBlockProps { | ||
| quote: NonNullable<Pattern["expertQuote"]>; | ||
| } | ||
|
|
||
| export function ExpertQuoteBlock({ quote }: ExpertQuoteBlockProps) { | ||
| return ( | ||
| <section | ||
| id="expert-quote" | ||
| aria-labelledby="expert-quote-heading" | ||
| className="scroll-mt-24" | ||
| > | ||
| <h2 id="expert-quote-heading" className="sr-only"> | ||
| Expert quote | ||
| </h2> | ||
| <figure className="rounded-sm border-l-2 border-accent/60 border-y border-r border-border-subtle bg-surface px-5 py-4"> | ||
| <blockquote className="text-body italic leading-7 text-text-primary [text-wrap:pretty]"> | ||
| {quote.text} | ||
| </blockquote> | ||
| <figcaption className="mt-3 text-meta text-text-tertiary"> | ||
| <span aria-hidden="true">— </span> | ||
| <a | ||
| href={quote.sourceUrl} | ||
| rel="noopener noreferrer" | ||
| target="_blank" | ||
| className="text-accent underline underline-offset-4 hover:text-accent-muted" | ||
| > | ||
| {quote.attribution} | ||
| </a> | ||
| </figcaption> | ||
| </figure> | ||
| </section> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // --------------------------------------------------------------------------- | ||
| // KeyStatisticCallout | ||
| // --------------------------------------------------------------------------- | ||
| // Above-fold callout box that surfaces a single quantitative claim with a | ||
| // linked public source and the year of the claim. Designed to live just | ||
| // before the pattern's diagram so the most citable line of the page is | ||
| // visible in the reader's first viewport. | ||
| // | ||
| // Visibility: not wrapped in <DisclosureSection>. The claim must render | ||
| // unconditionally so AI crawlers and SERP snippets can extract it. | ||
|
|
||
| import type { Pattern } from "@/data/agentic-design-patterns/types"; | ||
|
|
||
| interface KeyStatisticCalloutProps { | ||
| statistic: NonNullable<Pattern["keyStatistic"]>; | ||
| } | ||
|
|
||
| function hostnameOf(url: string): string { | ||
| try { | ||
| return new URL(url).hostname.replace(/^www\./, ""); | ||
| } catch { | ||
| return url; | ||
| } | ||
| } | ||
|
|
||
| export function KeyStatisticCallout({ statistic }: KeyStatisticCalloutProps) { | ||
| return ( | ||
| <section | ||
| id="key-statistic" | ||
| aria-labelledby="key-statistic-heading" | ||
| className="scroll-mt-24" | ||
| > | ||
| <h2 id="key-statistic-heading" className="sr-only"> | ||
| Key statistic | ||
| </h2> | ||
| <div className="rounded-sm border border-border bg-surface p-5"> | ||
| <p className="text-body leading-7 text-text-primary [text-wrap:pretty]"> | ||
| {statistic.claim} | ||
| </p> | ||
| <p className="mt-3 text-meta text-text-tertiary"> | ||
| <a | ||
| href={statistic.sourceUrl} | ||
| rel="noopener noreferrer" | ||
| target="_blank" | ||
| className="font-mono text-xs text-accent underline underline-offset-4 hover:text-accent-muted" | ||
| > | ||
| {hostnameOf(statistic.sourceUrl)} → | ||
| </a> | ||
| <span className="mx-1.5 text-text-tertiary">·</span> | ||
| <span className="font-mono text-xs">{statistic.year}</span> | ||
| </p> | ||
| </div> | ||
| </section> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // --------------------------------------------------------------------------- | ||
| // RelatedQuestionsBlock | ||
| // --------------------------------------------------------------------------- | ||
| // Renders a visible Q&A list as <dl>/<dt>/<dd>. Sits after the decision | ||
| // matrix and before the "In the wild" table. Pairs 1:1 with the FAQPage | ||
| // JSON-LD emitted from generateFaqPageSchema(): the questions and answers | ||
| // in the JSON-LD must also be visible to the user so AI-search engines | ||
| // (Perplexity, ChatGPT, Gemini, Google AI Overviews) can verify the | ||
| // citation signal against rendered content — which means this component | ||
| // must NOT be wrapped in <DisclosureSection>. Note: Google deprecated the | ||
| // FAQ rich result in Search on 2026-05-07; the JSON-LD remains valuable as | ||
| // an AI-search citation signal rather than a SERP enhancement. See | ||
| // https://developers.google.com/search/docs/appearance/structured-data/faqpage. | ||
|
|
||
| import type { Pattern } from "@/data/agentic-design-patterns/types"; | ||
|
|
||
| interface RelatedQuestionsBlockProps { | ||
| questions: NonNullable<Pattern["relatedQuestions"]>; | ||
| } | ||
|
|
||
| export function RelatedQuestionsBlock({ questions }: RelatedQuestionsBlockProps) { | ||
| if (questions.length === 0) return null; | ||
|
|
||
| return ( | ||
| <section | ||
| id="common-questions" | ||
| aria-labelledby="common-questions-heading" | ||
| className="scroll-mt-24" | ||
| > | ||
| <h2 | ||
| id="common-questions-heading" | ||
| className="font-mono text-nav font-semibold uppercase tracking-[0.08em] text-text-tertiary" | ||
| > | ||
| Common questions | ||
| </h2> | ||
| <dl className="mt-4 flex flex-col gap-4"> | ||
| {questions.map((qa, idx) => ( | ||
| <div | ||
| key={idx} | ||
| className="rounded-sm border border-border-subtle bg-surface px-4 py-3" | ||
| > | ||
| <dt className="text-body font-semibold text-text-primary [text-wrap:pretty]"> | ||
| {qa.q} | ||
| </dt> | ||
| <dd className="mt-2 text-body leading-7 text-text-secondary [text-wrap:pretty]"> | ||
| {qa.a} | ||
| </dd> | ||
| </div> | ||
| ))} | ||
| </dl> | ||
| </section> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import type { CollectionBeforeChangeHook } from 'payload' | ||
|
|
||
| /** | ||
| * Payload beforeChange hook for the Posts collection. | ||
| * | ||
| * Maintains `dedicatedDateModified` as a deliberate signal of meaningful | ||
| * content changes — independent of Payload's auto-updated `updatedAt`, | ||
| * which fires on every admin save (toggling featured flag, swapping a tag, | ||
| * etc.). Used by `generateBlogPostingSchema` as the canonical | ||
| * `BlogPosting.dateModified` value. | ||
| * | ||
| * Semantics: | ||
| * - create operations: pass through unchanged (the post is new; an editor | ||
| * can fill `dedicatedDateModified` manually or leave it null). | ||
| * - update operations: Payload's `data` partial only contains fields the | ||
| * editor actually touched in this save, so presence of the key in | ||
| * `data` is the correct test for "editor set this field explicitly". | ||
| * - If `dedicatedDateModified` IS in the partial → respect the editor | ||
| * value, return data unchanged. | ||
| * - Else if `body`, `title`, or `summary` is in the partial (meaningful | ||
| * content changed) → stamp `data.dedicatedDateModified` with the | ||
| * current ISO timestamp. | ||
| * - Else → no-op (non-content field change like `featured`). | ||
| * | ||
| * The hook is non-blocking: it never throws and never rejects a save. | ||
| */ | ||
| const MEANINGFUL_FIELDS = ['body', 'title', 'summary'] as const | ||
|
|
||
| export const beforeChangeDedicatedDateModified: CollectionBeforeChangeHook = ({ | ||
| data, | ||
| operation, | ||
| }) => { | ||
| if (operation === 'create') { | ||
| return data | ||
| } | ||
|
|
||
| // Payload's `data` on update is a partial containing only the fields the | ||
| // editor changed. Presence of the key is the correct signal that the | ||
| // editor set the field explicitly — a value-vs-originalDoc comparison | ||
| // would treat any unchanged save as an editor override. | ||
| const editorSetField = data != null && 'dedicatedDateModified' in data | ||
|
|
||
| if (editorSetField) { | ||
| return data | ||
| } | ||
|
|
||
| const meaningfulContentChanged = | ||
| data != null && MEANINGFUL_FIELDS.some((field) => field in data) | ||
|
|
||
| if (meaningfulContentChanged) { | ||
| return { | ||
| ...data, | ||
| dedicatedDateModified: new Date().toISOString(), | ||
| } | ||
| } | ||
|
|
||
| return data | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION — the 12 new unit tests in this PR are all for |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION — This new visible
Common questionssection (and its siblingKeyStatisticCallout/ExpertQuoteBlock) is rendered with ascroll-mt-24anchor (#common-questions), butPatternStickyRail.tsx'sJUMP_LINKSarray isn't extended to surface them in the "On this page" rail. WhenrelatedQuestionsis later populated for a pattern, readers won't be able to jump to it from the rail.Suggested wiring (in
PatternStickyRail.tsx, replacing the staticJUMP_LINKSconstant with a per-pattern computation):Non-blocking because all 23 patterns are unpopulated for these fields today — but worth wiring before Category I content population so a populated FAQ block doesn't ship without rail navigation.