Skip to content

Commit

Permalink
Switch guides to emit faq structured data
Browse files Browse the repository at this point in the history
This potentially gives us more control over the presentation of the result
in external search applications.

Related to alphagov/govuk_publishing_components#1087
  • Loading branch information
sihugh committed Sep 5, 2019
1 parent eaa633d commit e013796
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/content_items/guide.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for :extra_head_content do %>
<%= machine_readable_metadata(
schema: :article,
schema: :faq,
canonical_url: @content_item.canonical_url
) %>
<% end %>
Expand Down
10 changes: 10 additions & 0 deletions test/integration/guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,14 @@ class GuideTest < ActionDispatch::IntegrationTest

assert_has_component_title(title)
end

test "guides show the faq page schema" do
setup_and_visit_content_item('guide')

schema_sections = page.find_all("script[type='application/ld+json']", visible: false)
schemas = schema_sections.map { |section| JSON.parse(section.text(:all)) }

qa_page_schema = schemas.detect { |schema| schema["@type"] == "FAQPage" }
assert_equal qa_page_schema["headline"], @content_item['title']
end
end

0 comments on commit e013796

Please sign in to comment.