Skip to content

Commit

Permalink
fix/dark-mode-giscus
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Feb 15, 2023
1 parent a835c56 commit 91bf842
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions components/Comment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BLOG from '@/blog.config'
import dynamic from 'next/dynamic'
import Tabs from '@/components/Tabs'
import { useGlobal } from '@/lib/global'
import React from 'react'
import { useRouter } from 'next/router'

Expand Down Expand Up @@ -50,7 +49,6 @@ const ValineComponent = dynamic(() => import('@/components/ValineComponent'), {
})

const Comment = ({ frontMatter }) => {
const { isDarkMode } = useGlobal()
const router = useRouter()

React.useEffect(() => {
Expand Down Expand Up @@ -87,7 +85,7 @@ const Comment = ({ frontMatter }) => {

{BLOG.COMMENT_GISCUS_REPO && (
<div key="Giscus">
<GiscusComponent isDarkMode={isDarkMode} className="px-2" />
<GiscusComponent className="px-2" />
</div>
)}

Expand Down
5 changes: 4 additions & 1 deletion components/Giscus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global'
import { Giscus } from '@giscus/react'

/**
Expand All @@ -8,8 +9,10 @@ import { Giscus } from '@giscus/react'
* @constructor
*/

const GiscusComponent = ({ isDarkMode }) => {
const GiscusComponent = () => {
const { isDarkMode } = useGlobal()
const theme = isDarkMode ? 'dark' : 'light'

return (
<Giscus
repo={BLOG.COMMENT_GISCUS_REPO}
Expand Down
2 changes: 1 addition & 1 deletion lib/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function GlobalContextProvider({ children }) {
const [lang, updateLang] = useState(BLOG.LANG)
const [locale, updateLocale] = useState(generateLocaleDict(BLOG.LANG))
const [theme, setTheme] = useState(BLOG.THEME)
const [isDarkMode, updateDarkMode] = useState(false)
const [isDarkMode, updateDarkMode] = useState(BLOG.APPEARANCE === 'dark')
const [onLoading, changeLoadingState] = useState(false)

useEffect(() => {
Expand Down

0 comments on commit 91bf842

Please sign in to comment.