Skip to content

Commit a383d3b

Browse files
committed
typescript errors fix
1 parent 4fc9b8b commit a383d3b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/CodeBlock.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ const highlighted = await codeToHtml(code, {
2020
const copyButtons = document.querySelectorAll('.copy-button');
2121

2222
copyButtons.forEach(button => {
23-
button.addEventListener('click', async function() {
23+
button.addEventListener('click', async function(this: HTMLButtonElement) {
2424
const code = this.dataset.code;
2525
const icon = this.querySelector('i');
2626

27+
if (!code || !icon) return;
28+
2729
try {
2830
await navigator.clipboard.writeText(code);
2931

0 commit comments

Comments
 (0)