Skip to content

Commit

Permalink
try to fix action
Browse files Browse the repository at this point in the history
  • Loading branch information
DidierRLopes committed Sep 15, 2024
1 parent 94073f2 commit 64b8e95
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions src/theme/BlogPostItem/index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
import { useBlogPost } from '@docusaurus/theme-common/internal';
import BlogPostItem from '@theme-original/BlogPostItem';
import React from 'react';
import React, { useEffect, useState } from 'react';
import BrowserOnly from '@docusaurus/BrowserOnly';
import useIsBrowser from '@docusaurus/useIsBrowser';

export default function BlogPostItemWrapper(props) {
const { metadata, isBlogPostPage } = useBlogPost();
const isBrowser = useIsBrowser();
const [theme, setTheme] = useState('light');

useEffect(() => {
if (isBrowser) {
setTheme(document.documentElement.getAttribute('data-theme') !== 'dark' ? 'light' : 'dark');
}
}, [isBrowser]);

return (
<>
<BlogPostItem {...props}>
{props.children}
{isBlogPostPage && (
<div>
<iframe
src={
document.documentElement.getAttribute('data-theme') !== 'dark'
? 'https://embeds.beehiiv.com/e1ef8c12-fc6d-4afa-8235-057b2e9bb6f3'
: 'https://embeds.beehiiv.com/2c2719b8-abe1-4f8b-8427-fb9c2361f059'
}
data-test-id="beehiiv-embed"
width="100%"
height="200"
frameBorder="0"
scrolling="no"
title="Didier newsletter"
/>
</div>
<BrowserOnly>
{() => (
<div>
<iframe
src={
theme === 'light'
? 'https://embeds.beehiiv.com/e1ef8c12-fc6d-4afa-8235-057b2e9bb6f3'
: 'https://embeds.beehiiv.com/2c2719b8-abe1-4f8b-8427-fb9c2361f059'
}
data-test-id="beehiiv-embed"
width="100%"
height="200"
frameBorder="0"
scrolling="no"
title="Didier newsletter"
/>
</div>
)}
</BrowserOnly>
)}
</BlogPostItem>
</>
);
}
}

0 comments on commit 64b8e95

Please sign in to comment.