Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions components/comments/cusdis.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { ReactCusdis } from 'react-cusdis'
import { useRouter } from 'next/router'
import { useConfig } from '@/contexts/config'
import { useTheme } from "@/contexts/theme";

export default function Cusdis ({ config, post }) {
const router = useRouter()
const { link, lang, appearance } = useConfig()
const { link, lang } = useConfig()
const { scheme } = useTheme()

return (
<ReactCusdis
key={`cusdis-${scheme}`}
attrs={{
pageId: post.id,
pageTitle: post.title,
pageUrl: link + router.asPath,
theme: appearance,
theme: scheme,
...config,
}}
lang={resolveLang(lang)}
Expand Down
11 changes: 4 additions & 7 deletions components/comments/utterances.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { useEffect, useRef } from 'react'
import { useConfig } from '@/contexts/config'
import { useTheme } from '@/contexts/theme'

export default function Utterances ({ config, post }) {
const { appearance } = useConfig()
const theme = {
auto: 'preferred-color-scheme',
light: 'github-light',
dark: 'github-dark',
}[appearance]
const { scheme } = useTheme()

const theme = scheme === 'dark' ? 'github-dark' : 'github-light'

const container = useRef()

Expand Down
2 changes: 1 addition & 1 deletion contexts/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const ThemeContext = createContext<Context>(undefined as any)
export function ThemeProvider ({ children }: BasicProps) {
const config = useConfig()

const [theme, setTheme] = useState<Theme>(config.appearance === 'auto' ? 'system' : config.appearnce)
const [theme, setTheme] = useState<Theme>(config.appearance === 'auto' ? 'system' : config.appearance)

const [prefersDark, setPrefersDark] = useState<boolean>()

Expand Down