Refactor anchor link generation logic

This commit is contained in:
Emile Bangma 2025-03-27 18:56:59 +01:00 committed by GitHub
parent 4cff705548
commit fc3df9aa01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,8 +41,9 @@ document.addEventListener("nav", () => {
document.addEventListener("nav", () => {
const els = document.querySelectorAll("a[role=anchor]")
for (let i = 0; i < els.length; i++) {
if (els[i].getAttribute("href")) {
const anchorLink = `${window.location.href}${els[i].getAttribute("href")}`
const href = els[i].getAttribute("href")
if (href) {
const anchorLink = new URL(href, window.location.href).toString()
const svgAnchor = els[i].innerHTML
function onClick() {
navigator.clipboard.writeText(anchorLink).then(