FIX: prevents rendering topic-category if empty (#9720)

This commit is contained in:
Joffrey JAFFEUX 2020-05-11 16:45:28 +02:00 committed by GitHub
parent a9cf680f76
commit addf9d62f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -1012,6 +1012,8 @@ class TopicsController < ApplicationController
respond_to do |format|
format.html do
@tags = SiteSetting.tagging_enabled ? @topic_view.topic.tags : []
@breadcrumbs = helpers.categories_breadcrumb(@topic_view.topic) || []
@description_meta = @topic_view.topic.excerpt.present? ? @topic_view.topic.excerpt : @topic_view.summary
store_preloaded("topic_#{@topic_view.topic.id}", MultiJson.dump(topic_view_serializer))
render :show

View File

@ -4,9 +4,8 @@
<%= render_topic_title(@topic_view.topic) %>
</h1>
<% if @breadcrumbs.present? || @tags.present? %>
<div class="topic-category" itemscope itemtype="http://schema.org/BreadcrumbList">
<% @breadcrumbs = categories_breadcrumb(@topic_view.topic) %>
<% if @breadcrumbs.present? %>
<% @breadcrumbs.each_with_index do |c, i| %>
<span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a href="<%= Discourse.base_url %><%= c[:url] %>" class="badge-wrapper bullet" itemprop="item">
@ -16,10 +15,7 @@
<meta itemprop="position" content="<%= i + 1 %>" />
</span>
<% end %>
<% end %>
<% if SiteSetting.tagging_enabled %>
<% @tags = @topic_view.topic.tags %>
<% if @tags.present? %>
<meta itemprop='keywords' content='<%= @tags.map(&:name).join(', ') %>'>
<div class='discourse-tags list-tags'>
@ -28,8 +24,8 @@
<% end %>
</div>
<% end %>
<% end %>
</div>
<% end %>
</div>
<%= server_plugin_outlet "topic_header" %>