Skip to content

Commit

Permalink
Merge pull request #131 from cookiescrumbs/amphtml-link
Browse files Browse the repository at this point in the history
Ability to create AMP links
  • Loading branch information
kpumuk committed Dec 6, 2016
2 parents 6ca4d51 + 024e3df commit afcbbc7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/meta_tags/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def render_open_search(tags)
# @param [Array<Tag>] tags a buffer object to store tag in.
#
def render_links(tags)
[ :canonical, :prev, :next, :author, :publisher, :image_src ].each do |tag_name|
[ :amphtml, :canonical, :prev, :next, :author, :publisher, :image_src ].each do |tag_name|
href = meta_tags.extract(tag_name)
if href.present?
@normalized_meta_tags[tag_name] = href
Expand Down
21 changes: 21 additions & 0 deletions spec/view_helper/links_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,25 @@
end
end
end

context 'displaying amphtml url' do
it 'should not display amphtml url by default' do
subject.display_meta_tags(site: 'someSite').tap do |meta|
expect(meta).to_not have_tag('link', with: { href: "http://example.com/base/url.amp", rel: "amphtml" })
end
end

it 'should display amphtml url when "set_meta_tags" used' do
subject.set_meta_tags(amphtml: 'http://example.com/base/url.amp')
subject.display_meta_tags(site: 'someSite').tap do |meta|
expect(meta).to have_tag('link', with: { href: "http://example.com/base/url.amp", rel: "amphtml" })
end
end

it 'should display default amphtml url' do
subject.display_meta_tags(site: 'someSite', amphtml: 'http://example.com/base/url.amp').tap do |meta|
expect(meta).to have_tag('link', with: { href: "http://example.com/base/url.amp", rel: "amphtml" })
end
end
end
end

0 comments on commit afcbbc7

Please sign in to comment.