StructuredDataScript
A type-safe component for adding structured data to the page.
Installation
Usage
import StructuredDataScript from "@/registry/new-york/StructuredDataScript/StructuredDataScript";
import type { Article, WithContext } from "schema-dts";
const articleData: WithContext<Article> = {
"@context": "https://schema.org",
"@type": "Article",
headline: "My Article Title",
author: {
"@type": "Person",
name: "John Doe",
},
datePublished: "2024-03-20",
};
export default function Example() {
return (
<>
<StructuredDataScript data={articleData} />
{/* Your page content */}
</>
);
}
References
- Next.js Structured Data Documentation
- Schema.org
- Google Rich Results Test
- Google Search Central - Structured Data
- Structured Data Search Gallery
Tools
- schema-dts - TypeScript types for Schema.org vocabulary
- SEO Meta 1 Copy - Chrome extension for testing structured data
- Schema.org Validator - Validate your structured data against Schema.org