We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4fc9b8b commit a383d3bCopy full SHA for a383d3b
src/components/CodeBlock.astro
@@ -20,10 +20,12 @@ const highlighted = await codeToHtml(code, {
20
const copyButtons = document.querySelectorAll('.copy-button');
21
22
copyButtons.forEach(button => {
23
- button.addEventListener('click', async function() {
+ button.addEventListener('click', async function(this: HTMLButtonElement) {
24
const code = this.dataset.code;
25
const icon = this.querySelector('i');
26
27
+ if (!code || !icon) return;
28
+
29
try {
30
await navigator.clipboard.writeText(code);
31
0 commit comments