-
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 1 commit
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,48 @@ | ||
| // --------------------------------------------------------------------------- | ||
| // 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(): per Google's structured-data | ||
| // guidelines, the questions and answers in the JSON-LD must also be visible | ||
| // to the user, so this component must NOT be wrapped in <DisclosureSection>. | ||
|
|
||
| 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,54 @@ | ||
| 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: when `body`, `title`, or `summary` actually changed | ||
| * (deep-equal compare via JSON serialization), and the editor has NOT | ||
| * manually set `dedicatedDateModified` in this save, stamp the field | ||
| * with the current ISO timestamp. Editor-supplied values are preserved. | ||
| * | ||
| * 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, | ||
| originalDoc, | ||
| operation, | ||
| }) => { | ||
| if (operation === 'create') { | ||
| return data | ||
| } | ||
|
|
||
| // If the editor manually changed dedicatedDateModified in this save, | ||
| // respect that value — do not overwrite. | ||
| const editorSetField = | ||
| data?.dedicatedDateModified !== originalDoc?.dedicatedDateModified | ||
|
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. IMPORTANT — the auto-stamp only fires on the first content edit of any post, then is frozen permanently.
Concrete walkthrough:
Net effect: the JSON-LD To detect the case "editor explicitly set this field in this save," you need to check whether const editorSetField = data !== undefined && "dedicatedDateModified" in dataThis treats "editor touched the field" as the key being present in the delta — regardless of value. Worth confirming against a manual save in the admin UI before shipping. Related: the No tests exist for this hook — see the separate SUGGESTION about coverage. |
||
|
|
||
| if (editorSetField) { | ||
| return data | ||
| } | ||
|
|
||
| const changed = MEANINGFUL_FIELDS.some((field) => { | ||
| return JSON.stringify(data?.[field]) !== JSON.stringify(originalDoc?.[field]) | ||
| }) | ||
|
|
||
| if (changed) { | ||
| 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.