0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
gretel-jsonld enables gretel gem to handle JSON-LD based breadcrumbs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

Runtime

>= 3.0.0
 Project Readme

gretel-jsonld

Gem Version CI Code Coverage

gretel-jsonld enables gretel gem to handle JSON-LD based breadcrumbs.

Installation

Add this line to your application's Gemfile:

gem 'gretel-jsonld'

And then execute:

$ bundle

Usage

First, run the installation generator with:

$ rails generate gretel:install

Next, define "crumbs" in config/breadcrumbs.rb:

# 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:

<%= jsonld_breadcrumbs %>

Finally, specify a current breadcrumb in each view:

<% breadcrumb :issue, @issue %>

This will generate the following breadcrumbs, marked up with JSON-LD (indented for readability):

<script type="application/ld+json">
  {
    "@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"
        }
      }
    ]
  }
</script>

Options

You can pass jsonld_breadcrumbs the same options as breadcrumbs:

<%= jsonld_breadcrumbs link_current_to_request_path: false %>

For further information, please see gretel's documentation.

Supported versions

gretel-jsonld supports gretel 3.0 or later without an upper version bound. The supported version ranges are:

gretel Rails Ruby
3.x 5.x 2.5 or later
4.x 5.1 through 7.1 2.5 or later
5.x 6.1 or later 3.0 or later

CI tests the latest releases in the lowest and current highest Rails majors for each gretel major.

Contributing

You should follow the steps below:

  1. Fork the repository
  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

License

The gem is available as open source under the terms of the MIT License.