// Copy code // Thanks Aleksandr // www.aleksandrhovhannisyan.com/blog/how-to-add-a-copy-to-clipboard-button-to-your-jekyll-blog/ const codeBlocks = document.querySelectorAll(“.code-header + .highlighter-rouge”); const copyCodeButtons = document.querySelectorAll(“.copy-code-button”);
copyCodeButtons.forEach((copyCodeButton, index) => {
const code = codeBlocks[index].innerText; copyCodeButton.addEventListener("click", () => { window.navigator.clipboard.writeText(code); copyCodeButton.classList.add("copied"); setTimeout(() => { copyCodeButton.classList.remove("copied"); copyCodeButton.blur(); }, 2000); });
});
// Show top page button after scrolling down. $(“#topbtn”).hide(); $(window).scroll(function() {
if ($(window).scrollTop() > 100) { $("#topbtn").fadeIn("slow"); } else { $("#topbtn").fadeOut("fast"); }
});