FEATURE: add category name in articleSection meta tag for schema. (#21004)

https://schema.org/DiscussionForumPosting
This commit is contained in:
Vinoth Kannan 2023-04-06 23:30:19 +05:30 committed by GitHub
parent fef279acd5
commit 7cedb911a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -36,6 +36,9 @@
<%- if include_crawler_content? %>
<div itemscope itemtype='http://schema.org/DiscussionForumPosting'>
<meta itemprop='headline' content='<%= @topic_view.title %>'>
<% if @topic_view.topic.category.present? %>
<meta itemprop='articleSection' content='<%= @topic_view.topic.category.name %>'>
<% end %>
<meta itemprop='keywords' content='<%= @tags.map(&:name).join(', ') %>'>
<div itemprop='publisher' itemscope itemtype="http://schema.org/Organization">
<meta itemprop='name' content='<%= SiteSetting.company_name.presence || SiteSetting.title %>'>

View File

@ -59,5 +59,6 @@ RSpec.describe "topics/show.html.erb" do
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)
expect(topic_schema.css('[itemprop="articleSection"]')[0]["content"]).to eq(topic.category.name)
end
end