Skip to content

Commit 1a28301

Browse files
committed
chore: format
1 parent 5f3cddf commit 1a28301

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
'use client'
2-
import { useEffect } from "react";
1+
'use client';
2+
import { useEffect } from 'react';
33

44
export default function MarkdownCopyListener() {
55
useEffect(() => {
6-
const copyBtns = document.querySelectorAll('button.copy-code-btn')
6+
const copyBtns = document.querySelectorAll('button.copy-code-btn');
77
copyBtns.forEach((btn) => {
88
(btn as HTMLButtonElement).addEventListener('click', () => {
9-
const codeBlockContent = btn.parentElement?.nextElementSibling?.textContent
9+
const codeBlockContent = btn.parentElement?.nextElementSibling?.textContent;
1010
if (codeBlockContent) {
1111
navigator.clipboard.writeText(codeBlockContent).then(() => {
12-
btn.textContent = 'Copied'
12+
btn.textContent = 'Copied';
1313
setTimeout(() => {
14-
btn.textContent = 'Copy'
15-
}, 2000)
16-
})
14+
btn.textContent = 'Copy';
15+
}, 2000);
16+
});
1717
}
18-
})
19-
})
18+
});
19+
});
2020

2121
return () => {
2222
copyBtns.forEach((btn) => {
23-
(btn as HTMLButtonElement).removeEventListener('click', () => { })
24-
})
25-
}
26-
}, [])
23+
(btn as HTMLButtonElement).removeEventListener('click', () => {});
24+
});
25+
};
26+
}, []);
2727

28-
return null
28+
return null;
2929
}

components/markdown.tsx

+13-11
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,19 @@ const Markdown = ({ markdown }: { markdown: string }) => {
7676
},
7777
);
7878

79-
return <>
80-
<article
81-
className="prose dark:prose-invert prose-pre:rounded-2xl prose-pre:bg-secondary/25"
82-
dangerouslySetInnerHTML={{
83-
__html: DOMPurify.sanitize(marked.parse(markdown) as string, {
84-
USE_PROFILES: { html: true },
85-
}),
86-
}}
87-
></article>
88-
<MarkdownCopyListener />
89-
</>
79+
return (
80+
<>
81+
<article
82+
className="prose dark:prose-invert prose-pre:rounded-2xl prose-pre:bg-secondary/25"
83+
dangerouslySetInnerHTML={{
84+
__html: DOMPurify.sanitize(marked.parse(markdown) as string, {
85+
USE_PROFILES: { html: true },
86+
}),
87+
}}
88+
></article>
89+
<MarkdownCopyListener />
90+
</>
91+
);
9092
};
9193

9294
export default Markdown;

0 commit comments

Comments
 (0)