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 eab210e commit 1da5895
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/components/Artalk.astro
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
---
import Artalk from 'artalk';
import { useEffect } from 'react';
const { siteKey, siteName } = Astro.props;
useEffect(() => {
const artalk = new Artalk({
el: '#Comments',
site: ittst,
server: 'https://artalk.loliko.cn',
});
// 添加 loaded 类名以触发转场效果
document.getElementById('artalk-container').classList.add('loaded');
return () => {
artalk.destroy();
};
}, [siteKey, siteName]);
---
<style>
#Comments {
Expand All @@ -29,4 +11,20 @@ useEffect(() => {
opacity: 1;
}
</style>
<div id="Comments"></div>
<div id="Comments"></div>
<script is:inline>
import Artalk from 'artalk';
// 初始化 Artalk
const initArtalk = () => {
const artalk = new Artalk({
el: '#Comments',
site: 'ittst',
server: 'https://artalk.loliko.cn',
});

// 添加 loaded 类名以触发转场效果
document.getElementById('Comments').classList.add('loaded');
};
// 在页面加载完成后初始化 Artalk
window.addEventListener('load', initArtalk);
</script>

0 comments on commit 1da5895

Please sign in to comment.