forked from tangly1024/NotionNext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CusdisComponent.js
31 lines (27 loc) · 955 Bytes
/
CusdisComponent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { useGlobal } from '@/lib/global'
import BLOG from '@/blog.config'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import { loadExternalResource } from '@/lib/utils'
const CusdisComponent = ({ frontMatter }) => {
const { locale } = useGlobal()
const router = useRouter()
const { isDarkMode } = useGlobal()
// 处理cusdis主题
useEffect(() => {
loadExternalResource(BLOG.COMMENT_CUSDIS_SCRIPT_SRC, 'js').then(url => {
const CUSDIS = window.CUSDIS
CUSDIS?.initial()
})
}, [isDarkMode])
return <div id="cusdis_thread"
lang={locale.LOCALE.toLowerCase()}
data-host={BLOG.COMMENT_CUSDIS_HOST}
data-app-id={BLOG.COMMENT_CUSDIS_APP_ID}
data-page-id={frontMatter.id}
data-page-url={BLOG.LINK + router.asPath}
data-page-title={frontMatter.title}
data-theme={isDarkMode ? 'dark' : 'light'}
></div>
}
export default CusdisComponent