StructuredData
Installation
Add this line to your application's Gemfile:
gem 'structured_data'
And then execute:
$ bundle
Or install it yourself as:
$ gem install structured_data
Usage
repo = StructuredData::Repository.new
= StructuredData::BreadcrumbList.new
<< { url: '/products', name: 'Products' }
<< { url: '/products/book', name: 'Book' }
repo <<
repo.dump
[{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "/products",
"name": "Products"
}
},
{
"@type": "ListItem",
"position": 2,
"item": {
"@id": "/products/book",
"name": "Book"
}
}
]
}]
Rails support
Call the helper method in Controller or View
= set_breadcrumb_item(url: '/products', name: 'Products')
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/ukstudio/structured_data.