mirror of
https://github.com/iyear/tdl
synced 2025-01-09 04:17:35 +08:00
docs(prj): open bookHref in the same tab
This commit is contained in:
parent
e884f6208e
commit
9e4ec0d27d
10
docs/layouts/partials/docs/inject/footer.html
Normal file
10
docs/layouts/partials/docs/inject/footer.html
Normal file
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
// hugo-book set all bookHref links to open in a new tab, this script will change it to open in the same tab
|
||||
// detect all href attributes, if it's not an external link, set target to _self
|
||||
const links = document.querySelectorAll('a[href]');
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
if (links[i].hostname === window.location.hostname) {
|
||||
links[i].target = '_self';
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user