Files
sim/apps/docs/components/structured-data.tsx
Waleed 03f2029e66 improvement(seo): fix soft 404s, per-integration freshness, and docs markdown for AI crawlers (#9006)
* improvement(seo): fix soft 404s, per-integration freshness, and docs markdown for AI crawlers

* test(seo): crawl the production build for landing SEO regressions

* chore(landing): remove the post and author loading skeletons the slug pages no longer use

* fix(seo): resolve docs slugs through the catalog, keep API pages negotiable, and harden the crawler suite

* fix(docs): carry the landing-page backlink into integration markdown

* test(seo): match the visible date attribute case-insensitively
2026-10-13 23:04:08 -07:00

93 lines
2.1 KiB
TypeScript

import { serializeJsonLd } from '@/lib/json-ld'
import { DOCS_BASE_URL, SIM_SITE_URL } from '@/lib/urls'
interface StructuredDataProps {
title: string
description: string
url: string
dateModified?: string
breadcrumb?: Array<{ name: string; url: string }>
}
export function StructuredData({
title,
description,
url,
dateModified,
breadcrumb,
}: StructuredDataProps) {
const baseUrl = DOCS_BASE_URL
const structuredDataId = encodeURIComponent(url)
const articleStructuredData = {
'@context': 'https://schema.org',
'@type': 'TechArticle',
headline: title,
description: description,
url: url,
...(dateModified && { dateModified }),
author: {
'@type': 'Organization',
'@id': `${SIM_SITE_URL}#organization`,
name: 'Sim',
url: SIM_SITE_URL,
},
publisher: {
'@type': 'Organization',
'@id': `${SIM_SITE_URL}#organization`,
name: 'Sim',
url: SIM_SITE_URL,
logo: {
'@type': 'ImageObject',
url: `${baseUrl}/static/logo.png`,
},
},
mainEntityOfPage: {
'@type': 'WebPage',
'@id': url,
},
inLanguage: 'en',
isPartOf: {
'@type': 'WebSite',
name: 'Sim Documentation',
url: baseUrl,
},
potentialAction: {
'@type': 'ReadAction',
target: url,
},
}
const breadcrumbStructuredData = breadcrumb && {
'@context': 'https://schema.org',
'@type': 'BreadcrumbList',
itemListElement: breadcrumb.map((item, index) => ({
'@type': 'ListItem',
position: index + 1,
name: item.name,
item: item.url,
})),
}
return (
<>
<script
id={`article-json-ld-${structuredDataId}`}
type='application/ld+json'
dangerouslySetInnerHTML={{
__html: serializeJsonLd(articleStructuredData),
}}
/>
{breadcrumbStructuredData && (
<script
id={`breadcrumb-json-ld-${structuredDataId}`}
type='application/ld+json'
dangerouslySetInnerHTML={{
__html: serializeJsonLd(breadcrumbStructuredData),
}}
/>
)}
</>
)
}