-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use canonical_url specified in page if present #211
Conversation
lib/jekyll-seo-tag/drop.rb
Outdated
@@ -183,7 +183,11 @@ def page_lang | |||
|
|||
def canonical_url | |||
@canonical_url ||= begin | |||
filters.absolute_url(page["url"]).to_s.gsub(%r!/index\.html$!, "/") | |||
if page["canonical_url"].present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.present?
only works in Rails. You'll want to use to_s.empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know that. Will update this with specified changes.
spec/jekyll_seo_tag/drop_spec.rb
Outdated
let(:page) { make_page( { "title" => "page title", "canonical_url" => "https://github.com/jekyll/jekyll-seo-tag/"} ) } | ||
let(:canonical_url) { 'https://github.com/jekyll/jekyll-seo-tag/' } | ||
it "uses specified canonical url" do | ||
puts subject.canonical_url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray puts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove puts, is this proper way to test or I need to create and use posts fixtures? I am not sure about this part 😅
@8parth this is great, and thanks for working through our feedback. I made a few minor formatting changes, but think this should be good to merge. Thank you! |
assign the canonical url to canonical_url specified by user in page otherwise use default generated url.