Skip to content

Commit

Permalink
add sitelinks search
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed authored and cbeer committed Sep 9, 2015
1 parent 5d7082d commit 21c232f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/views/catalog/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<% unless has_search_parameters? %>
<%# if there are no input/search related params, display the "home" partial -%>
<%= render 'home' %>
<%= render 'shared/sitelinks_search_box' %>
<% else %>
<%= render 'search_results' %>
<% end %>
Expand Down
12 changes: 12 additions & 0 deletions app/views/shared/_sitelinks_search_box.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "<%= root_url %>",
"potentialAction": {
"@type": "SearchAction",
"target": "<%= root_url %>?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
12 changes: 12 additions & 0 deletions spec/features/sitelinks_search_box.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'spec_helper'

feature 'Sitelinks search box' do
scenario 'is home page' do
visit root_path
expect(page).to have_css 'script[type="application/ld+json"]'
end
scenario 'on search page' do
visit catalog_index_path q: 'book'
expect(page).to_not have_css 'script[type="application/ld+json"]'
end
end

1 comment on commit 21c232f

@jrochkind
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.