Skip to content

Commit

Permalink
Update fence.astro
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfieJones committed Jun 10, 2024
1 parent b9f9a5a commit 82c281b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions apps/marketing-astro/src/components/schema/fence.astro
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,22 @@ const { code, lang, title } = Astro.props;
</div>

<script>
const btns = document.querySelectorAll("[data-clipboard-text]");
function initCopy() {
const btns = document.querySelectorAll("[data-clipboard-text]");

btns.forEach((btn) => {
btn.addEventListener("click", async (e) => {
const text = btn.getAttribute("data-clipboard-text")!;
await navigator.clipboard.writeText(text);
btn.setAttribute("data-coppied", "true");
setTimeout(() => {
btn.setAttribute("data-coppied", "false");
}, 3000);
btns.forEach((btn) => {
btn.addEventListener("click", async (e) => {
const text = btn.getAttribute("data-clipboard-text")!;
await navigator.clipboard.writeText(text);
btn.setAttribute("data-coppied", "true");
setTimeout(() => {
btn.setAttribute("data-coppied", "false");
}, 3000);
});
});
});
}
initCopy();
document.addEventListener("astro:after-swap", initCopy);
</script>

<style is:global>
Expand Down

0 comments on commit 82c281b

Please sign in to comment.