fix: giscus comment

This commit is contained in:
KazooTTT
2024-11-23 22:03:59 +08:00
parent 9f392106bd
commit ebcc468e7e
4 changed files with 13 additions and 4 deletions

View File

@ -6,6 +6,15 @@ import Giscus from '@giscus/react'
const id = 'inject-comments'
const GiscusComment = () => {
const [theme, setTheme] = React.useState('preferred_color_scheme')
React.useEffect(() => {
const savedTheme = localStorage.getItem('theme')
if (savedTheme) {
setTheme(savedTheme)
}
}, [])
return (
<div id={id} className='mt-8 w-full'>
<Giscus
@ -19,7 +28,7 @@ const GiscusComment = () => {
reactionsEnabled='1'
emitMetadata='0'
inputPosition='bottom'
theme={localStorage.getItem('theme') ?? 'preferred_color_scheme'}
theme={theme}
lang='zh-CN'
loading='lazy'
/>

View File

@ -23,5 +23,5 @@ const { Content } = await entry.render()
<PostLayout post={entry}>
<Content />
<GiscusComment client:only='react' client:load />
<GiscusComment client:load />
</PostLayout>

View File

@ -211,5 +211,5 @@ const projects = [...directProjects, ...mdProjects].slice(0, MAX_PROJECTS)
</div>
</Section>
</div>
<GiscusComment client:only='react' client:load />
<GiscusComment client:load />
</PageLayout>

View File

@ -408,5 +408,5 @@ const DEVICES = {
<CategorySection title='Hardware Devices' categories={Object.values(DEVICES)} />
</div>
</div>
<GiscusComment client:only='react' client:load />
<GiscusComment client:load />
</PageLayout>