jonbio/components/Comments.tsx

23 lines
577 B
TypeScript
Raw Normal View History

2023-07-16 18:52:51 +08:00
'use client'
import { Comments as CommentsComponent } from 'pliny/comments'
import { useState } from 'react'
import siteMetadata from '@/data/siteMetadata'
export default function Comments({ slug }: { slug: string }) {
2024-04-01 14:29:08 +05:00
const [loadComments, setLoadComments] = useState(false)
if (!siteMetadata.comments?.provider) {
2024-04-01 14:29:08 +05:00
return null
}
2023-07-16 18:52:51 +08:00
return (
2024-04-01 14:29:08 +05:00
<>
{loadComments ? (
2023-07-16 18:52:51 +08:00
<CommentsComponent commentsConfig={siteMetadata.comments} slug={slug} />
2024-04-01 14:29:08 +05:00
) : (
<button onClick={() => setLoadComments(true)}>Load Comments</button>
)}
</>
2023-07-16 18:52:51 +08:00
)
}