Skip to content

Commit

Permalink
chore: remove dynaic discus
Browse files Browse the repository at this point in the history
  • Loading branch information
khj0426 committed Dec 6, 2024
1 parent 74d62e6 commit b1e3581
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 20 deletions.
45 changes: 45 additions & 0 deletions components/Gitcus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use client'

import { useEffect, useRef } from 'react'
import { useTheme } from 'next-themes'

export default function Giscus() {
const ref = useRef<HTMLDivElement>(null)
const { resolvedTheme } = useTheme()
const theme = resolvedTheme === 'dark' ? 'dark' : 'light'

useEffect(() => {
if (!ref.current || ref.current.hasChildNodes()) return

const scriptElem = document.createElement('script')
scriptElem.src = 'https://giscus.app/client.js'
scriptElem.async = true
scriptElem.crossOrigin = 'anonymous'

scriptElem.setAttribute('data-repo', 'WE-ARE-RACCOONS/RACCOONS')
scriptElem.setAttribute('data-repo-id', 'R_kgDONOeDQg')
scriptElem.setAttribute('data-mapping', 'pathname')
scriptElem.setAttribute('data-strict', '0')
scriptElem.setAttribute('data-reactions-enabled', '1')
scriptElem.setAttribute('data-emit-metadata', '0')
scriptElem.setAttribute('data-input-position', 'bottom')
scriptElem.setAttribute('data-theme', theme)
scriptElem.setAttribute('data-lang', 'ko')
ref.current.style.width = '100%'

ref.current.appendChild(scriptElem)
}, [theme])

return (
<section
ref={ref}
style={{
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
margin: '0 auto',
}}
/>
)
}
16 changes: 14 additions & 2 deletions components/Comments.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
'use client'

import Giscus from './Gitcus'
import Giscus from './\bGitcus'

export default function Comments({ slug }: { slug: string }) {
return <Giscus />
return (
<div
style={{
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
margin: '0 auto',
}}
>
<Giscus />
</div>
)
}
16 changes: 0 additions & 16 deletions components/Gitcus.tsx

This file was deleted.

1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"prepare": "husky"
},
"dependencies": {
"@giscus/react": "^3.0.0",
"@headlessui/react": "2.2.0",
"@next/bundle-analyzer": "15.0.2",
"@tailwindcss/forms": "^0.5.9",
Expand Down

0 comments on commit b1e3581

Please sign in to comment.