google / google/react-schemaorg

How to make BreadcrumbList with multiple breadcrumb trails

Offen
#47 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
521
Forks
20
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

According to the Google docs [here](https://developers.google.com/search/docs/appearance/structured-data/breadcrumb#html_example) 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(
[{
"@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)
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne bei der Typsignatur von jsonLdScriptProps() und verfolge, wie deren Eingabe dargestellt und gerendert wird. Ermittle, ob BreadcrumbList[] akzeptiert werden kann, wobei das bestehende Verhalten mit einem einzelnen Objekt erhalten bleibt, und überprüfe anschließend, dass das resultierende JSON-LD die angeforderten mehreren Breadcrumb-Pfade enthält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
react, typescript
Bereich
api
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.