Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yasaichi/gretel-jsonld
Gretel extension for supporting JSON-LD breadcrumbs :bread:
https://github.com/yasaichi/gretel-jsonld
breadcrumbs json-ld rails
Last synced: 2 months ago
JSON representation
Gretel extension for supporting JSON-LD breadcrumbs :bread:
- Host: GitHub
- URL: https://github.com/yasaichi/gretel-jsonld
- Owner: yasaichi
- License: mit
- Created: 2017-11-18T06:47:51.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T08:22:37.000Z (about 1 year ago)
- Last Synced: 2024-11-29T14:45:16.213Z (3 months ago)
- Topics: breadcrumbs, json-ld, rails
- Language: Ruby
- Homepage:
- Size: 56.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# gretel-jsonld
[![Gem Version](https://badge.fury.io/rb/gretel-jsonld.svg)](http://badge.fury.io/rb/gretel-jsonld)
[![Build Status](https://travis-ci.org/yasaichi/gretel-jsonld.svg?branch=master)](https://travis-ci.org/yasaichi/gretel-jsonld)
[![Code Climate](https://api.codeclimate.com/v1/badges/fc3fd5037eb200bedbf5/maintainability)](https://codeclimate.com/github/yasaichi/gretel-jsonld/maintainability)
[![Test Coverage](https://codeclimate.com/github/yasaichi/gretel-jsonld/badges/coverage.svg)](https://codeclimate.com/github/yasaichi/gretel-jsonld/coverage)gretel-jsonld enables gretel gem to handle JSON-LD based breadcrumbs.
## Installation
Add this line to your application's `Gemfile`:
```ruby
gem 'gretel-jsonld'
```And then execute:
```bash
$ bundle
```## Usage
First, run the installation generator with:
```sh
$ rails generate gretel:install
```Next, define "crumbs" in `config/breadcrumbs.rb`:
```ruby
# See also: https://github.com/lassebunk/gretel#more-examples# Root crumb
crumb :root do
link 'Home', root_path
end# Issue list
crumb :issues do
link 'All issues', issues_path
end# Issue
crumb :issue do |issue|
link issue.title, issue
parent :issues
end
```Then, add this line to your application's layout:
```erb
<%= jsonld_breadcrumbs %>
```Finally, specify a current breadcrumb in each view:
```erb
<% breadcrumb :issue, @issue %>
```This will generate the following breadcrumbs, marked up with JSON-LD (indented for readability):
```html
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "/",
"name": "Home"
}
},
{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "/issues",
"name": "All issues"
}
},
{
"@type": "ListItem",
"position": 3,
"item": {
"@id": "/issues/46",
"name": "My Issue"
}
}
]
}```
## Options
You can pass `jsonld_breadcrumbs` the same options as `breadcrumbs`:
```erb
<%= jsonld_breadcrumbs link_current_to_request_path: false %>
```For further information, please see [gretel's documentation](https://github.com/WilHall/gretel/blob/develop/README.md#options).
## Supported versions
Note that gretel-jsonld doesn't support all versions of gretel, Ruby and Rails:
- gretel: gretel-jsonld supports **only 3.x** for now
- Ruby: gretel 3.x supports **1.9.3 or later**, but gretel-jsonld does **only 2.2.2 or later**
- Rails: gretel 3.x supports **3.1 or later**, but gretel-jsonld does **only 3.2 or later**## Contributing
You should follow the steps below:
1. [Fork the repository](https://help.github.com/articles/fork-a-repo/)
2. Create a feature branch: `git checkout -b add-new-feature`
3. Commit your changes: `git commit -am 'Add new feature'`
4. Push the branch: `git push origin add-new-feature`
5. [Send us a pull request](https://help.github.com/articles/about-pull-requests/)## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).