Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created November 30, 2022 00:56
Show Gist options
  • Save sibelius/af24052edf88c3c824d0627d9248699a to your computer and use it in GitHub Desktop.
Save sibelius/af24052edf88c3c824d0627d9248699a to your computer and use it in GitHub Desktop.
Embed Browser Only for docusuarus
import React from 'react';
import BrowserOnly from '@docusaurus/BrowserOnly';
import { useColorMode } from '@docusaurus/theme-common';
const Embed = (props) => {
const { isDarkTheme } = useColorMode();
return (
<BrowserOnly>
{() => {
const EmbedComponent = require('react-embed').default;
return <EmbedComponent isDark={isDarkTheme} {...props} />;
}}
</BrowserOnly>
);
};
export default Embed;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment