Skip to content
Snippets Groups Projects

Add schema markup to breadcrumb

Merged Francisco Javier López requested to merge 36844-fj-add-schema-to-breadcrumb-json into master
All threads resolved!
Files
7
@@ -12,7 +12,7 @@ def add_to_breadcrumbs(text, link)
def breadcrumb_title_link
return @breadcrumb_link if @breadcrumb_link
request.path
"#{request.base_url}#{request.path}"
end
def breadcrumb_title(title)
@@ -32,4 +32,31 @@ def add_to_breadcrumb_dropdown(link, location: :before)
@breadcrumb_dropdown_links[location] ||= []
@breadcrumb_dropdown_links[location] << link
end
def push_to_schema_breadcrumb(text, link)
schema_breadcrumb_list.push(schema_list_item(text, link, schema_breadcrumb_list.size + 1))
end
def schema_breadcrumb_json
{
'@context': 'https://schema.org',
'@type': 'BreadcrumbList',
'itemListElement': schema_breadcrumb_list
}.to_json
end
private
def schema_breadcrumb_list
@schema_breadcrumb_list ||= []
end
def schema_list_item(text, link, position)
{
'@type' => 'ListItem',
'position' => position,
'name' => text,
'item' => link
}
end
end
Loading