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 96e94ba commit 80c66ee
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/Artalk.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ const { site, server } = Astro.props;
});

document.addEventListener('astro:before-swap', event => {
// Pass the incoming document to initialize Artalk on it
// 自定义交换实现
event.swap = () => {
diff(document, event.newDocument);
};

// 初始化 Artalk
initializeArtalk(event.newDocument);
});

function diff(oldDocument, newDocument) {
// 自定义的 diff 实现
// 例如,比较两个文档的全部内容
console.log('Custom swap implementation');
// 这里可以添加你自己的逻辑
}
</script>

0 comments on commit 80c66ee

Please sign in to comment.