// Copy buttons on code blocks. The site works without this file. document.querySelectorAll("article pre").forEach((pre) => { const button = document.createElement("button"); button.className = "copy"; button.type = "button"; button.textContent = "copy"; button.addEventListener("click", () => { const text = pre.querySelector("code")?.textContent ?? pre.textContent; navigator.clipboard.writeText(text).then( () => { button.textContent = "copied"; }, () => { button.textContent = "failed"; }, ); setTimeout(() => { button.textContent = "copy"; }, 1500); }); pre.append(button); });