tailwind-nextjs-blog/components/Comments.tsx

20 lines
569 B
TypeScript
Raw Normal View History

2023-08-16 23:55:57 +08:00
'use client';
2023-08-16 23:55:57 +08:00
import { Comments as CommentsComponent } from 'pliny/comments';
import { useState } from 'react';
import siteMetadata from '@/data/siteMetadata';
export default function Comments({ slug }: { slug: string }) {
2023-08-16 23:55:57 +08:00
const [loadComments, setLoadComments] = useState(false);
return (
<>
2023-08-16 23:55:57 +08:00
{!loadComments && (
<button onClick={() => setLoadComments(true)}>Load Comments</button>
)}
{siteMetadata.comments && loadComments && (
<CommentsComponent commentsConfig={siteMetadata.comments} slug={slug} />
)}
</>
2023-08-16 23:55:57 +08:00
);
}