FEATURE: subcategories can be discovered by web crawlers on page 1 of the parent category topics list

This commit is contained in:
Neil Lalonde 2017-03-02 15:06:47 -05:00
parent 4dac4c69a6
commit ca20cb9941
2 changed files with 27 additions and 5 deletions

View File

@ -294,6 +294,10 @@ class ListController < ApplicationController
@description_meta = @category.description_text
raise Discourse::NotFound unless guardian.can_see?(@category)
if use_crawler_layout?
@subcategories = @category.subcategories.select { |c| guardian.can_see?(c) }
end
end
def build_topic_list_options

View File

@ -13,16 +13,34 @@
<% if @category %>
<h1>
<% if @category.parent_category %>
<%= link_to @category.parent_category.url, itemprop: 'item' do %>
<span itemprop='name'><%= @category.parent_category.name %></span>
<% end %>
&nbsp;
<%= link_to @category.parent_category.url, itemprop: 'item' do %>
<span itemprop='name'><%= @category.parent_category.name %></span>
<% end %>
&nbsp;
<% end %>
<%= link_to @category.url, itemprop: 'item' do %>
<span itemprop='name'><%= @category.name %></span>
<% end %>
</h1>
<br/>
<% if params[:page].to_i == 0 && @subcategories.present? %>
<div itemscope itemtype='http://schema.org/ItemList'>
<% @subcategories.each do |subcategory| %>
<div itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
<meta itemprop='url' content='<%= subcategory.url %>'>
<a href='<%= subcategory.url %>' itemprop='item'>
<span itemprop='name'><%= subcategory.name %></span>
</a>
<% if subcategory.description.present? %>
<span itemprop='description'><%= subcategory.description %></span>
<% end %>
</div>
<% end %>
</div>
<br/>
<% end %>
<% end %>
<div class='topic-list' itemscope itemtype='http://schema.org/ItemList'>
@ -58,7 +76,7 @@
<% end %>
<% end %>
<%- end %>
<%- end %> <!-- include_crawler_content? -->
<% if @rss %>
<% content_for :head do %>