import React from 'react'; import siteMetadata from '@/data/siteMetadata'; import dynamic from 'next/dynamic'; import { PostFrontMatter } from 'types/PostFrontMatter'; interface Props { frontMatter: PostFrontMatter; } const UtterancesComponent = dynamic( () => { return import('@/components/comments/Utterances'); }, { ssr: false } ); const GiscusComponent = dynamic( () => { return import('@/components/comments/Giscus'); }, { ssr: false } ); const DisqusComponent = dynamic( () => { return import('@/components/comments/Disqus'); }, { ssr: false } ); const CusdisComponent = dynamic( () => { return import('@/components/comments/Cusdis'); }, { ssr: false } ); const CommentoComponent = dynamic( () => { return import('@/components/comments/Commento'); }, { ssr: false } ); const Comments = ({ frontMatter }: Props) => { let term; switch ( siteMetadata.comment.giscusConfig.mapping || siteMetadata.comment.utterancesConfig.issueTerm ) { case 'pathname': term = frontMatter.slug; break; case 'url': term = window.location.href; break; case 'title': term = frontMatter.title; break; } return (
{siteMetadata.comment && siteMetadata.comment.provider === 'giscus' && ( )} {siteMetadata.comment && siteMetadata.comment.provider === 'utterances' && ( )} {siteMetadata.comment && siteMetadata.comment.provider === 'disqus' && ( )} {siteMetadata.comment && siteMetadata.comment.provider === 'cusdis' && ( )} {siteMetadata.comment && siteMetadata.comment.provider === 'commento' && ( )}
); }; export default Comments;