Add copy article button with full Markdown source

This commit is contained in:
2026-09-23 13:21:39 -07:00
parent 98a226f8b6
commit 3d842c4957
17 changed files with 1694 additions and 1623 deletions
+16
View File
@@ -7,6 +7,22 @@ Alpine.start();
const bootIcons = () => createIcons({ icons });
const copyArticleButton = document.querySelector("[data-copy-article]");
if (copyArticleButton) {
let resetTimer;
copyArticleButton.addEventListener("click", async () => {
const label = copyArticleButton.querySelector("span");
clearTimeout(resetTimer);
try {
await navigator.clipboard.writeText(JSON.parse(document.querySelector("#article-markdown").textContent));
label.textContent = "Copied!";
} catch {
label.textContent = "Copy failed";
}
resetTimer = setTimeout(() => (label.textContent = "Copy article"), 2500);
});
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", bootIcons);
} else {