FEATURE: add opengraph and twitter meta tags on every page

This commit is contained in:
Arpit Jalan 2016-08-19 17:04:43 +05:30
parent 0a1d7896bf
commit a39929d12e
6 changed files with 22 additions and 1 deletions

View File

@ -148,6 +148,8 @@ module ApplicationHelper
opts[:image] = "#{uri.scheme}:#{opts[:image]}"
elsif opts[:image].present? && opts[:image].start_with?("/uploads/")
opts[:image] = "#{Discourse.base_url}#{opts[:image]}"
elsif SiteSetting.default_opengraph_image_url.present?
opts[:image] = SiteSetting.default_opengraph_image_url
end
# Add opengraph tags

View File

@ -104,3 +104,7 @@
<br/>
<% end %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: SiteSetting.title, description: SiteSetting.site_description) %>
<% end %>

View File

@ -12,3 +12,7 @@
</div>
<% content_for :title do %><%= @title %><% end %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: SiteSetting.title, description: SiteSetting.site_description) %>
<% end %>

View File

@ -65,6 +65,10 @@
<%= auto_discovery_link_tag(:rss, { action: :category_feed }, title: t('rss_topics_in_category', category: @category.name)) %>
<%= raw crawlable_meta_data(title: @category.name, description: @category.description) %>
<% end %>
<% else %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: SiteSetting.title, description: SiteSetting.site_description) %>
<% end %>
<% end %>
<% if @title %>

View File

@ -23,4 +23,11 @@
<% if @title %>
<% content_for :title do %><%= @title %><% end %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: @title, description: SiteSetting.site_description) %>
<% end %>
<% else %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: SiteSetting.title, description: SiteSetting.site_description) %>
<% end %>
<% end %>

View File

@ -174,7 +174,7 @@ class TopicView
# show poster avatar
@desired_post.user.avatar_template_url.gsub("{size}", "100") if @desired_post.user
else
@topic.image_url || SiteSetting.default_opengraph_image_url
@topic.image_url
end
end