diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/QuestionSummary.astro | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/components/QuestionSummary.astro b/src/components/QuestionSummary.astro index 96ec6f8..9b70955 100644 --- a/src/components/QuestionSummary.astro +++ b/src/components/QuestionSummary.astro @@ -12,6 +12,7 @@ * * <QuestionSummary * headline="ページのタイトル" + * about="障害者虐待" * datePublished="2025-06-06" * qa={[ * { question: "① 質問文", answer: "答弁テキスト", anchor: "-見出し名" }, @@ -25,7 +26,8 @@ * - question: 表の「質問」列の内容(番号付きで) * - answer: 表の「答弁概要」列のテキスト(リンク構文なしのプレーンテキスト) * - anchor: 詳細セクションへのアンカー(見出しから自動生成されるID) - * - headline: ページのタイトル(JSON-LD の headline に使われる) + * - headline: ページのタイトル + * - about: 質問の主題(1〜3語のキーワード。JSON-LD WebPage.about に使われる) * - datePublished: 質問日(ISO 8601: YYYY-MM-DD) */ @@ -43,29 +45,42 @@ export interface Props { qa: QA[]; /** ページの表題 */ headline?: string; + /** 質問の主題(1〜3語。例: "障害者虐待"、"いじめ重大事態"、"公文書管理") */ + about?: string; /** 公開日(ISO 8601形式: YYYY-MM-DD) */ datePublished?: string; } -const { qa, headline, datePublished } = Astro.props; +const { qa, headline, about, datePublished } = Astro.props; --- { qa.length > 0 && ( <script type="application/ld+json" is:inline set:html={JSON.stringify({ - "@context": "https://schema.org", - "@type": "FAQPage", - ...(headline && { headline }), - ...(datePublished && { datePublished }), - "mainEntity": qa.map((item) => ({ - "@type": "Question", - "name": item.question, - "acceptedAnswer": { - "@type": "Answer", - "text": item.answer, - }, - })), -})} /> + "@context": "https://schema.org", + "@graph": [ + { + "@type": "WebPage", + ...(headline && { name: headline }), + ...(about && { about: { "@type": "Thing", name: about } }), + ...(datePublished && { datePublished }), + "mainEntity": { "@id": "#faq" }, + }, + { + "@type": "FAQPage", + "@id": "#faq", + ...(headline && { headline }), + "mainEntity": qa.map((item) => ({ + "@type": "Question", + "name": item.question, + "acceptedAnswer": { + "@type": "Answer", + "text": item.answer, + }, + })), + }, + ].filter(Boolean), + })} /> ) } |
