File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' pliny ' : patch
3+ ---
4+
5+ Corrected cors error in disqus
Original file line number Diff line number Diff line change 1+ import { useTheme } from 'next-themes'
12import { useEffect , useCallback } from 'react'
23
34export interface DisqusConfig {
@@ -12,28 +13,25 @@ export type DisqusProps = DisqusConfig['disqusConfig'] & {
1213}
1314
1415export const Disqus = ( { shortname, slug } : DisqusProps ) => {
16+ const { theme } = useTheme ( )
17+
1518 const COMMENTS_ID = 'disqus_thread'
1619
1720 const LoadComments = useCallback ( ( ) => {
18- //@ts -ignore
1921 window . disqus_config = function ( ) {
2022 this . page . url = window . location . href
2123 this . page . identifier = slug
2224 }
23- //@ts -ignore
2425 if ( window . DISQUS === undefined ) {
2526 const script = document . createElement ( 'script' )
2627 script . src = 'https://' + shortname + '.disqus.com/embed.js'
27- // @ts -ignore
28- script . setAttribute ( 'data-timestamp' , + new Date ( ) )
29- script . setAttribute ( 'crossorigin' , 'anonymous' )
28+ script . setAttribute ( 'data-timestamp' , Date . now ( ) . toString ( ) )
3029 script . async = true
3130 document . body . appendChild ( script )
3231 } else {
33- //@ts -ignore
34- window . DISQUS . reset ( { reload : true } )
32+ ; ( window as any ) . DISQUS . reset ( { reload : true } )
3533 }
36- } , [ shortname , slug ] )
34+ } , [ shortname , slug , theme ] )
3735
3836 useEffect ( ( ) => {
3937 LoadComments ( )
You can’t perform that action at this time.
0 commit comments