Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ryohidaka/react-breadcrumbs-jsonld

Dynamically generates JSON-LD structured for breadcrumbs in React.
https://github.com/ryohidaka/react-breadcrumbs-jsonld

json-ld react react-component schema-org seo

Last synced: about 1 month ago
JSON representation

Dynamically generates JSON-LD structured for breadcrumbs in React.

Awesome Lists containing this project

README

        

# react-breadcrumbs-jsonld

[![npm version](https://badge.fury.io/js/react-breadcrumbs-jsonld.svg)](https://badge.fury.io/js/react-breadcrumbs-jsonld)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

## Overview

Dynamically generates JSON-LD structured for breadcrumbs in React.

## Installation

You can install this library using npm:

```shell
npm install react-breadcrumbs-jsonld
```

## Usage

- `url` must be an absolute path.
- Must begin with either `http` or `https`.
- URLs must be recursively nested.

### Example

```tsx
import { BreadcrumbSchema, BreadcrumbItem } from "react-breadcrumbs-jsonld";

function App() {
const breadcrumbs: BreadcrumbItem[] = [
{ url: "https://example.com/", name: "Home" },
{ url: "https://example.com/product/", name: "Products" },
{ url: "https://example.com/product/hoge", name: "Hoge" },
];

return (
<>

>
);
}
```

### Output

```html

{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "https://example.com/",
"name": "Home"
}
},
{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "https://example.com/product/",
"name": "Products"
}
},
{
"@type": "ListItem",
"position": 3,
"item": {
"@id": "https://example.com/product/hoge",
"name": "Hoge"
}
}
]
}

```

### Schema.org Test Result

Test Result

## Link

- [Breadcrumb (BreadcrumbList) structured data](https://developers.google.com/search/docs/appearance/structured-data/breadcrumb)
- [Schema.org](http://schema.org/)
- [schema-dts](https://github.com/google/schema-dts)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.