Delete src/components/Twikoo.astro

This commit is contained in:
2026-06-14 18:41:12 +08:00
committed by GitHub
parent 12bea5f93c
commit 498fbf116e
-38
View File
@@ -1,38 +0,0 @@
---
// src/components/Twikoo.astro
---
<div id="twikoo"></div>
<script>
function loadTwikoo() {
// 动态导入Twikoo,避免SSR问题
import('twikoo').then((twikoo) => {
twikoo.init({
envId: 'http://47.108.235.131:8080', // 改成你的Worker域名
el: '#twikoo',
path: window.location.pathname,
lang: 'zh-CN',
});
});
}
// 页面首次加载
loadTwikoo();
// 【关键】视图过渡路由兼容
document.addEventListener('astro:page-load', () => {
// 清空容器,避免重复渲染
const container = document.getElementById('twikoo');
if (container) {
container.innerHTML = '';
loadTwikoo();
}
});
</script>
<style>
#twikoo {
margin-top: 2rem;
}
</style>