Skip to content

Commit

Permalink
feat: open external link in new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Christiani committed Mar 28, 2024
1 parent 71ce40c commit 8711db6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ export function decorateLinkedIcons(spanList) {
});
}

function decorateLinks(main) {
main.querySelectorAll('a').forEach((ele) => {
if (!ele.href.startsWith(window.location.origin)) {
ele.setAttribute('target', '_blank');
}
})

Check failure on line 53 in scripts/scripts.js

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
}

/**
* Builds hero block and prepends to main in a new section.
* @param {Element} main The container element
Expand Down Expand Up @@ -97,6 +105,7 @@ export function decorateMain(main) {
buildAutoBlocks(main);
decorateSections(main);
decorateBlocks(main);
decorateLinks(main);
}

/**
Expand Down

0 comments on commit 8711db6

Please sign in to comment.