tailwind-nextjs-blog/components/comments/Commento.tsx

34 lines
797 B
TypeScript
Raw Normal View History

2022-10-17 23:37:01 +08:00
import React, { useMemo, useState } from 'react';
2022-10-17 23:37:01 +08:00
import siteMetadata from '@/data/siteMetadata';
import { PostFrontMatter } from 'types/PostFrontMatter';
import { useTheme } from 'next-themes';
import ReactCommento from './commento/ReactCommento';
interface Props {
2022-10-17 23:37:01 +08:00
frontMatter: PostFrontMatter;
}
const Commento = ({ frontMatter }: Props) => {
2022-10-17 23:37:01 +08:00
const { resolvedTheme } = useTheme();
const commentsTheme = useMemo(() => {
switch (resolvedTheme) {
case 'light':
case 'dark':
2022-10-17 23:37:01 +08:00
return resolvedTheme;
default:
2022-10-17 23:37:01 +08:00
return 'auto';
}
2022-10-17 23:37:01 +08:00
}, [resolvedTheme]);
return (
<div className="my-2">
2022-10-17 23:37:01 +08:00
<ReactCommento
url={siteMetadata.comment.commentoConfig.url}
pageId={frontMatter.slug}
/>
</div>
2022-10-17 23:37:01 +08:00
);
};
2022-10-17 23:37:01 +08:00
export default Commento;