google / google/react-schemaorg

How to make BreadcrumbList with multiple breadcrumb trails

Aperta
#47 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
521
Fork
20
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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)
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Parti dalla firma del tipo di jsonLdScriptProps() e segui il modo in cui il suo input viene rappresentato e renderizzato. Determina se è possibile accettare BreadcrumbList[] preservando il comportamento esistente per un singolo oggetto, quindi verifica che il JSON-LD risultante contenga i molteplici percorsi breadcrumb richiesti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
react, typescript
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.