Skip to content

Commit

Permalink
Update Artalk.astro
Browse files Browse the repository at this point in the history
  • Loading branch information
jkjoy committed Oct 29, 2024
1 parent 114cbc6 commit e046871
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/components/Artalk.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ const { site, server } = Astro.props;
<link href="https://artalk.loliko.cn/dist/Artalk.css" rel="stylesheet">
<script src="https://artalk.loliko.cn/dist/Artalk.js"></script>
<div id="Comments"></div>
<script>
document.addEventListener('astro:before-swap', () => {
<script is:inline>
function initializeArtalk(document) {
Artalk.init({
el: '#Comments',
server: {server},
site: {site},
});
});
document.addEventListener('astro:before-swap', () => {
Artalk.init({
el: '#Comments',
server: {server},
site: {site},
}
document.addEventListener('DOMContentLoaded', () => {
initializeArtalk(document);
});

document.addEventListener('astro:before-swap', event => {
// Pass the incoming document to initialize Artalk on it
initializeArtalk(event.newDocument);
});
});
</script>

0 comments on commit e046871

Please sign in to comment.