Complete the code to add JSON-LD structured data inside a Next.js component.
import Script from 'next/script'; export default function Product() { return ( <> <h1>Product Page</h1> <Script type="application/ld+json" id="product-jsonld"> {JSON.stringify([1])} </Script> </> ); }
You need to pass a valid JSON-LD object inside JSON.stringify() to embed structured data.
Complete the code to add a JSON-LD breadcrumb list in Next.js.
import Script from 'next/script'; export default function Breadcrumb() { const breadcrumb = { "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ { "@type": "ListItem", "position": 1, "name": "Home", "item": "https://example.com" }, { "@type": "ListItem", "position": 2, "name": "[1]", "item": "https://example.com/products" } ] }; return ( <Script type="application/ld+json" id="breadcrumb-jsonld"> {JSON.stringify(breadcrumb)} </Script> ); }
The second breadcrumb item should be named "Products" to match the URL and page context.
Fix the error in the JSON-LD script by completing the missing key.
const jsonLd = {
"@context": "https://schema.org",
"@type": "Article",
"headline": "How to use JSON-LD",
[1]: "John Doe"
};publisher instead of authorThe key for the article's writer is author. This fixes the missing key error.
Fill both blanks to create a JSON-LD object for a local business with name and address.
const localBusiness = {
"@context": "https://schema.org",
"@type": "LocalBusiness",
"name": [1],
"address": {
"@type": "PostalAddress",
"streetAddress": [2]
}
};The business name should be a string like "Joe's Cafe", and the street address should be "123 Main St".
Fill all three blanks to create a JSON-LD object for an event with name, startDate, and location.
const event = {
"@context": "https://schema.org",
"@type": "Event",
"name": [1],
"startDate": [2],
"location": {
"@type": "Place",
"name": [3]
}
};The event name is a string, the startDate must be in ISO format string, and the location name is a string.