From b3540992523a0356b6e110c6760ef2e05707957e Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Tue, 15 Aug 2017 19:23:03 +0530 Subject: [PATCH] FEATURE: add custom open graph tag for ignoring canonical url --- app/helpers/application_helper.rb | 4 ++++ app/views/topics/show.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1d837bbf0b0..64316cc4746 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -212,6 +212,10 @@ module ApplicationHelper result << tag(:meta, name: 'twitter:data2', value: "#{opts[:like_count]} ❤") end + if opts[:ignore_canonical] + result << tag(:meta, property: 'og:ignore_canonical', content: true) + end + result.join("\n") end diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index d228518bd26..68dad7ec1ca 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -88,7 +88,7 @@ <% content_for :head do %> <%= auto_discovery_link_tag(@topic_view, {action: :feed, slug: @topic_view.topic.slug, topic_id: @topic_view.topic.id}, title: t('rss_posts_in_topic', topic: @topic_view.title), type: 'application/rss+xml') %> - <%= raw crawlable_meta_data(title: @topic_view.title, description: @topic_view.summary, image: @topic_view.image_url, read_time: @topic_view.read_time, like_count: @topic_view.like_count) %> + <%= raw crawlable_meta_data(title: @topic_view.title, description: @topic_view.summary, image: @topic_view.image_url, read_time: @topic_view.read_time, like_count: @topic_view.like_count, ignore_canonical: true) %> <% if @topic_view.prev_page || @topic_view.next_page %> <% if @topic_view.prev_page %>