'use client'
import { SandpackCodeViewer, SandpackFiles, SandpackProvider } from '@codesandbox/sandpack-react'
import { useTheme } from 'next-themes'
import { useEffect, useState } from 'react'
export const Code = (props: any) => {
if (!props.className) {
return
}
const language = props.className.replace('language-', '')
return
}
export function CodeBlock({ code }: { code: SandpackFiles }) {
const [isClientSide, setIsClientSide] = useState(false)
const { theme } = useTheme()
useEffect(() => setIsClientSide(true), [])
// This is to avoid hydration mismatch between the server and the client because of the useTheme.
if (!isClientSide) {
return null
}
const trimmedCode = Object.fromEntries(
Object.entries(code).map(([key, value]) => [key, (value as string).trim()])
)
return (
)
}