added the option to link older site comments

This commit is contained in:
2022-09-17 20:26:51 +02:00
parent 35c0956f9b
commit c752310aa0
5 changed files with 8 additions and 4 deletions

View File

@@ -7,9 +7,10 @@ import { useSiteMetadata } from "@/hooks";
interface Props {
postTitle: string;
postSlug: string;
disqusId?: string;
}
const Comments: React.FC<Props> = ({ postTitle, postSlug }: Props) => {
const Comments: React.FC<Props> = ({ postTitle, postSlug, disqusId }: Props) => {
const { url, disqusShortname } = useSiteMetadata();
if (!disqusShortname) {
@@ -21,7 +22,7 @@ const Comments: React.FC<Props> = ({ postTitle, postSlug }: Props) => {
shortname={disqusShortname}
config={{
url: url + postSlug,
identifier: postTitle,
identifier: disqusId ?? postTitle,
title: postTitle,
}}
/>

View File

@@ -14,7 +14,7 @@ interface Props {
const Post: React.FC<Props> = ({ post }: Props) => {
const { html } = post;
const { tagSlugs, slug } = post.fields;
const { tags, title, date } = post.frontmatter;
const { tags, title, date, disqusId } = post.frontmatter;
return (
<div className={styles.post}>
@@ -29,7 +29,7 @@ const Post: React.FC<Props> = ({ post }: Props) => {
</div>
<div className={`${styles.comments} hideInPrintView`}>
<Comments postSlug={slug} postTitle={post.frontmatter.title} />
<Comments disqusId={disqusId} postSlug={slug} postTitle={post.frontmatter.title} />
</div>
</div>
);

View File

@@ -45,6 +45,7 @@ export const query = graphql`
tags
title
socialImage
disqusId
}
}
}

View File

@@ -6,6 +6,7 @@ interface Frontmatter {
description?: string;
tags?: Array<string>;
socialImage?: string;
disqusId?: string;
}
export default Frontmatter;