From 80c66ee107ea52d9f3efa7389597c8a5acb6a55d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AA=E5=AD=90?= Date: Tue, 29 Oct 2024 11:05:33 +0800 Subject: [PATCH] Update Artalk.astro --- src/components/Artalk.astro | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/Artalk.astro b/src/components/Artalk.astro index 931ea70..c7a240d 100644 --- a/src/components/Artalk.astro +++ b/src/components/Artalk.astro @@ -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'); + // 这里可以添加你自己的逻辑 + }