fix: client load

This commit is contained in:
KazooTTT
2024-11-23 21:57:41 +08:00
parent 7e78500e45
commit 9f392106bd
4 changed files with 413 additions and 425 deletions

View File

@ -1,18 +1,13 @@
'use client'
import React from 'react' import React from 'react'
import Giscus from '@giscus/react' import Giscus from '@giscus/react'
const id = 'inject-comments' const id = 'inject-comments'
const GiscusComment = () => { const GiscusComment = () => {
const [mounted, setMounted] = React.useState(false)
React.useEffect(() => {
setMounted(true)
}, [])
return ( return (
<div id={id} className='mt-8 w-full'> <div id={id} className='mt-8 w-full'>
{mounted ? (
<Giscus <Giscus
id={id} id={id}
repo='KazooTTT/kazoottt-blog' repo='KazooTTT/kazoottt-blog'
@ -28,7 +23,6 @@ const GiscusComment = () => {
lang='zh-CN' lang='zh-CN'
loading='lazy' loading='lazy'
/> />
) : null}
</div> </div>
) )
} }

View File

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

View File

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

View File

@ -14,7 +14,7 @@ const SOFTWARE_TOOLS = {
{ {
name: 'WindSurf', name: 'WindSurf',
description: 'AI-Powered IDE', description: 'AI-Powered IDE',
href: 'https://windsurf.app/', href: 'https://windsurf.app/'
}, },
{ {
name: 'Cursor', name: 'Cursor',
@ -403,16 +403,10 @@ const DEVICES = {
<p>Tools, software, and devices I use daily</p> <p>Tools, software, and devices I use daily</p>
</div> </div>
<CategorySection <CategorySection title='Software Tools' categories={Object.values(SOFTWARE_TOOLS)} />
title="Software Tools"
categories={Object.values(SOFTWARE_TOOLS)}
/>
<CategorySection <CategorySection title='Hardware Devices' categories={Object.values(DEVICES)} />
title="Hardware Devices"
categories={Object.values(DEVICES)}
/>
</div> </div>
</div> </div>
<GiscusComment client:only='react' /> <GiscusComment client:only='react' client:load />
</PageLayout> </PageLayout>