feat: switch to static tweets

This commit is contained in:
Travis Fischer
2021-02-14 23:31:06 -05:00
parent 07c5421248
commit 0add28665a
9 changed files with 906 additions and 17 deletions

View File

@@ -9,6 +9,8 @@ import BodyClassName from 'react-body-classname'
import useDarkMode from 'use-dark-mode'
import { PageBlock } from 'notion-types'
import { Tweet, Twitter } from 'react-static-tweets'
// core notion renderer
import { NotionRenderer, Code, Collection, CollectionRow } from 'react-notion-x'
@@ -57,12 +59,9 @@ const Equation = dynamic(() =>
import('react-notion-x').then((notion) => notion.Equation)
)
const Tweet = dynamic(
() => import('react-notion-x').then((notion) => notion.Tweet),
{
ssr: false
}
)
// we're now using a much lighter-weight tweet renderer react-static-tweets
// instead of the official iframe-based embed widget from twitter
// const Tweet = dynamic(() => import('react-tweet-embed'))
const Modal = dynamic(
() => import('react-notion-x').then((notion) => notion.Modal),
@@ -162,7 +161,15 @@ export const NotionPage: React.FC<types.PageProps> = ({
}
return (
<>
<Twitter.Provider
value={{
tweetAstMap: recordMap.tweetAstMap || {},
swrOptions: {
fetcher: (id) =>
fetch(`/api/get-tweet-ast/${id}`).then((r) => r.json())
}
}}
>
<PageHead site={site} />
<Head>
@@ -274,6 +281,6 @@ export const NotionPage: React.FC<types.PageProps> = ({
<GitHubShareButton />
<CustomHtml site={site} />
</>
</Twitter.Provider>
)
}