FEATURE: use "Comment" schema type for post replies. (#20932)

Previously, we used the schema type "DiscussionForumPosting" for all the posts including replies. This is not recommended as per Google search experts. This commit changes the schema type to "Comment" for replies.
This commit is contained in:
Vinoth Kannan
2023-04-03 14:36:47 +05:30
committed by GitHub
parent 046560926f
commit 8405ec2831
2 changed files with 92 additions and 76 deletions

View File

@@ -43,4 +43,21 @@ RSpec.describe "topics/show.html.erb" do
expect(first_item.css('[itemprop="position"]')[0]["content"]).to eq("1")
expect(first_item.css('[itemprop="url"]')[0]["href"]).to eq("https://example.com/")
end
it "uses comment scheme type for replies" do
view.stubs(:crawler_layout?).returns(true)
view.stubs(:include_crawler_content?).returns(true)
Fabricate(:post, topic: topic)
Fabricate(:post, topic: topic)
Fabricate(:post, topic: topic)
assign(:topic_view, TopicView.new(topic))
assign(:tags, [])
render template: "topics/show", formats: [:html]
doc = Nokogiri::HTML5.fragment(rendered)
topic_schema = doc.css('[itemtype="http://schema.org/DiscussionForumPosting"]')
expect(topic_schema.size).to eq(1)
expect(topic_schema.css('[itemtype="http://schema.org/Comment"]').size).to eq(2)
end
end