FIX: Handle encoding on onebox excerpt

Oneboxes were breaking with bad encoding using the out of the box
excerpt on the topic. Mimicked core behaviors instead.
This commit is contained in:
Justin DiRose 2020-10-05 16:17:38 -05:00
parent 30aa6230c5
commit 310f2f142c
No known key found for this signature in database
GPG Key ID: 1855147B46436A53
2 changed files with 4 additions and 1 deletions

View File

@ -27,6 +27,9 @@ module KnowledgeExplorer
raise Discourse::NotFound raise Discourse::NotFound
end end
@excerpt = @topic.posts[0].excerpt(500, { strip_links: true, text_entities: true }) if @topic.posts[0].present?
@excerpt = (@excerpt || "").gsub(/\n/, ' ').strip
query["topic"] = get_topic(@topic, current_user) query["topic"] = get_topic(@topic, current_user)
end end

View File

@ -1,3 +1,3 @@
<% content_for :head do %> <% content_for :head do %>
<%= raw crawlable_meta_data(title: @topic["title"], description: @topic["excerpt"]) if @topic %> <%= raw crawlable_meta_data(title: @topic["title"], description: @excerpt) if @topic %>
<% end %> <% end %>