Skip to content
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

How to make BreadcrumbList with multiple breadcrumb trails #47

Open
StewartJ-SSG opened this issue Nov 10, 2022 · 0 comments
Open

How to make BreadcrumbList with multiple breadcrumb trails #47

StewartJ-SSG opened this issue Nov 10, 2022 · 0 comments

Comments

@StewartJ-SSG
Copy link

According to the Google docs here it should be possible to have multiple BreadcrumbList items in an array inside the script tag. However, this doesn't seem possible with react-schemaorg since you cannot pass an array of objects to jsonLdScriptProps() you can only pass a single object.

What I would like to do is:

  const data = jsonLdScriptProps<BreadcrumbList[]>(
[{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "@id": "/#breadcrumlist",
    itemListElement: [
      {
        "@type": "ListItem",
        position: 1,
        name: "Articles",
        item: "https://example.com/",
      },
      {
        "@type": "ListItem",
        position: 2,
        name: "Archive",
        item: `https://example.com/a/${utcYear}/${utcMonth}/`,
      },
    ],
  },
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "@id": "/#breadcrumlist",
    itemListElement: [
      {
        "@type": "ListItem",
        position: 1,
        name: "Home",
        item: "https://example.com/",
      },
      {
        "@type": "ListItem",
        position: 2,
        name: `${section}`,
        item: `https://example.com/sections/${section}/`,
      },
    ],
  },
);

But this generates an error:

Type 'BreadcrumbListLeaf[]' does not satisfy the constraint 'Thing'.
  Property '"@type"' is missing in type 'BreadcrumbListLeaf[]' but required in type 'TouristDestinationLeaf'.ts(2344)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant