Last active
October 19, 2019 02:52
-
-
Save tomholford/5233c7148fa5ecb31fe921a79c475de1 to your computer and use it in GitHub Desktop.
Revisions
-
tomholford revised this gist
Oct 19, 2019 . 1 changed file with 10 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,15 @@ 1. Add the following to `app/helpers/application_helper.rb`: ```ruby def external_link_to(name = nil, options = nil, html_options = nil, &block) opts = { target: '_blank', rel: 'nofollow noopener' } if block_given? options ||= {} options = options.merge(opts) else html_options ||= {} html_options = html_options.merge(opts) end link_to(name, options, html_options, &block) end ``` -
tomholford revised this gist
Jun 25, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ <%= external_link_to 'Github', 'https://github.com/' %> ``` Or, with html options like a class (also wrapping an image tag): ```erb <%= external_link_to image_tag('github.svg'), 'https://github.com/', class: 'icon-link' %> ``` -
tomholford revised this gist
Jun 25, 2019 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ 1. Add the following to `app/helpers/application_helper.rb`: ```ruby def external_link_to(name, path, **html_options) link_to name, path, { target: '_blank', rel: 'nofollow noopener' }.merge(html_options) end ``` @@ -10,5 +10,10 @@ <%= external_link_to 'Github', 'https://github.com/' %> ``` Or with html options, like a class: ```erb <%= external_link_to image_tag('github.svg'), 'https://github.com/', class: 'icon-link' %> ``` More info on the extra link attributes here: https://developers.google.com/web/tools/lighthouse/audits/noopener -
tomholford renamed this gist
Jun 25, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tomholford created this gist
Jun 25, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ 1. Add the following to `app/helpers/application_helper.rb`: ```ruby def external_link_to(name, path) link_to name, path, target: '_blank', rel: 'nofollow noopener' end ``` 2. Use it like so in a view template: ```erb <%= external_link_to 'Github', 'https://github.com/' %> ``` More info on the extra link attributes here: https://developers.google.com/web/tools/lighthouse/audits/noopener