Move the QAPage Question into mainEntity

Fixes
https://meta.discourse.org/t/support-schema-org-qapage-and-google-rich-results/33813/14?u=notriddle
This commit is contained in:
Michael Howell 2018-12-04 20:04:54 +00:00
parent 5ddf911df8
commit 684df58437
1 changed files with 3 additions and 8 deletions

View File

@ -246,10 +246,6 @@ SQL
}
}
page_json = {
'@type' => 'QAPage',
'name' => topic&.title,
}
if accepted_answer = Post.find_by(id: topic.custom_fields["accepted_answer_post_id"])
question_json[:acceptedAnswer] = {
'@type' => 'Answer',
@ -266,10 +262,9 @@ SQL
['<script type="application/ld+json">', MultiJson.dump(
'@context' => 'http://schema.org',
'@graph' => [
page_json,
question_json,
]
'@type' => 'QAPage',
'name' => topic&.title,
'mainEntity' => question_json
).gsub("</", "<\\/").html_safe, '</script>'].join("")
end