Skip to content

Commit

Permalink
fixup! feat(web): ouvre les liens externes dans un nouvel onglet
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Parisot committed May 5, 2019
1 parent 2cacd4d commit edad568
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/asciidoctor-external-links-attributes.js
@@ -0,0 +1,23 @@
'use strict';

module.exports = function externalLinksAttributes () {
this.docinfoProcessor(function(){
this.process(({backend}) => {
if (backend !== 'html5') {
return '';
}

return `<script>
(function(d){
const {origin} = window.location;
Array.from(document.querySelectorAll('a[href]'))
.filter(link => link.href.indexOf(origin) !== 0)
.forEach(link => {
link.setAttribute('target', '_blank');
link.setAttribute('rel', 'noopener');
});
})(document);</script>`;
});
});
};

0 comments on commit edad568

Please sign in to comment.