File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7070// export default GiscusComments;
7171
7272import React , { useEffect , useRef } from "react" ;
73+ import { useLocation } from "@docusaurus/router" ;
7374import { useColorMode } from "@docusaurus/theme-common" ;
7475
75- const GiscusComments : React . FC = ( ) => {
76+ type GiscusCommentsProps = {
77+ forceRender ?: boolean ;
78+ } ;
79+
80+ const GiscusComments : React . FC < GiscusCommentsProps > = ( {
81+ forceRender = false ,
82+ } ) => {
7683 const ref = useRef < HTMLDivElement > ( null ) ;
84+ const { pathname } = useLocation ( ) ;
7785 const { colorMode } = useColorMode ( ) ; // colorMode is 'light' or 'dark'
86+ const isBlogPostPage = pathname . startsWith ( "/blog/" ) ;
87+
88+ if ( isBlogPostPage && ! forceRender ) {
89+ return null ;
90+ }
7891
7992 // 1. This useEffect handles the initial script loading ONCE.
8093 useEffect ( ( ) => {
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { useBlogPost } from "@docusaurus/plugin-content-blog/client";
55import BlogPostItemFooterOriginal from "@theme-original/BlogPostItem/Footer" ;
66import type BlogPostItemFooterType from "@theme/BlogPostItem/Footer" ;
77import type { WrapperProps } from "@docusaurus/types" ;
8+ import GiscusComments from "../../../components/giscus" ;
89import SocialShare from "../../../components/SocialShare" ;
910import { getAuthorProfile } from "../../../utils/authors" ;
1011
@@ -149,6 +150,7 @@ export default function BlogPostItemFooterWrapper(props: Props): JSX.Element {
149150 </ div >
150151 </ section >
151152 ) }
153+ { isBlogPostPage && < GiscusComments forceRender /> }
152154 </ >
153155 ) ;
154156}
You can’t perform that action at this time.
0 commit comments