jakstys.lt/themes/default/layouts/partials/external-links.html
Motiejus Jakštys 0bc0ea4577 Add 'jakstys.lt/themes/default/' from commit '641a854a0a705a5ddbb3badeb2bc23cc079f9de6'
git-subtree-dir: jakstys.lt/themes/default
git-subtree-mainline: b82ef4c7a5626048be31904c02f41567b158f043
git-subtree-split: 641a854a0a705a5ddbb3badeb2bc23cc079f9de6
2022-04-11 18:28:03 +03:00

19 lines
567 B
HTML

{{ if or .Site.Params.ExternalLinkIcon .Site.Params.ExternalLinkNewWindow -}}
<script>
window.onload = function() {
var links = document.getElementsByTagName('a');
for (var i in links) {
if (links[i].nodeType != 1) continue;
if (links[i].hostname != window.location.hostname) {
{{- if .Site.Params.ExternalLinkIcon }}
links[i].className += 'external';
{{- end }}
{{- if .Site.Params.ExternalLinkNewWindow }}
links[i].setAttribute('target', '_blank');
{{- end }}
}
}
}
</script>
{{ end -}}