Merge pull request #843 from talhatahir/main

fix: update comments component incase of no provider
This commit is contained in:
Timothy 2024-04-04 23:08:01 +09:00 committed by GitHub
commit f88e368113
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,11 +6,16 @@ import siteMetadata from '@/data/siteMetadata'
export default function Comments({ slug }: { slug: string }) { export default function Comments({ slug }: { slug: string }) {
const [loadComments, setLoadComments] = useState(false) const [loadComments, setLoadComments] = useState(false)
if (!siteMetadata.comments?.provider) {
return null
}
return ( return (
<> <>
{!loadComments && <button onClick={() => setLoadComments(true)}>Load Comments</button>} {loadComments ? (
{siteMetadata.comments && loadComments && (
<CommentsComponent commentsConfig={siteMetadata.comments} slug={slug} /> <CommentsComponent commentsConfig={siteMetadata.comments} slug={slug} />
) : (
<button onClick={() => setLoadComments(true)}>Load Comments</button>
)} )}
</> </>
) )