Skip to content

Commit 8163ce1

Browse files
feat: revert to using official twitter embedding sdk; bump deps
1 parent aed9b20 commit 8163ce1

File tree

8 files changed

+27
-852
lines changed

8 files changed

+27
-852
lines changed

components/NotionPage.tsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import BodyClassName from 'react-body-classname'
99
import { useTheme } from 'next-themes'
1010
import { PageBlock } from 'notion-types'
1111

12-
import { Tweet, TwitterContextProvider } from 'react-static-tweets'
12+
import TweetEmbed from 'react-tweet-embed'
1313

1414
// core notion renderer
1515
import { NotionRenderer } from 'react-notion-x'
@@ -104,6 +104,10 @@ const Modal = dynamic(
104104
}
105105
)
106106

107+
const Tweet = ({ id }: { id: string }) => {
108+
return <TweetEmbed tweetId={id} />
109+
}
110+
107111
const propertyLastEditedTimeValue = (
108112
{ block, pageHeader },
109113
defaultFn: () => React.ReactNode
@@ -172,20 +176,6 @@ export const NotionPage: React.FC<types.PageProps> = ({
172176
[]
173177
)
174178

175-
const twitterContextValue = React.useMemo(() => {
176-
if (!recordMap) {
177-
return null
178-
}
179-
180-
return {
181-
tweetAstMap: (recordMap as any).tweetAstMap || {},
182-
swrOptions: {
183-
fetcher: (id: string) =>
184-
fetch(`/api/get-tweet-ast/${id}`).then((r) => r.json())
185-
}
186-
}
187-
}, [recordMap])
188-
189179
// lite mode is for oembed
190180
const isLiteMode = lite === 'true'
191181

@@ -262,7 +252,7 @@ export const NotionPage: React.FC<types.PageProps> = ({
262252
}
263253

264254
return (
265-
<TwitterContextProvider value={twitterContextValue}>
255+
<>
266256
<PageHead
267257
pageId={pageId}
268258
site={site}
@@ -300,6 +290,6 @@ export const NotionPage: React.FC<types.PageProps> = ({
300290
/>
301291

302292
<GitHubShareButton />
303-
</TwitterContextProvider>
293+
</>
304294
)
305295
}

lib/config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ export const isPreviewImageSupportEnabled: boolean = getSiteConfig(
7777
false
7878
)
7979

80-
// Optional whether or not to enable support for LQIP preview images
81-
export const isTweetEmbedSupportEnabled: boolean = getSiteConfig(
82-
'isTweetEmbedSupportEnabled',
83-
true
84-
)
85-
8680
// Optional whether or not to include the Notion ID in page URLs or just use slugs
8781
export const includeNotionIdInUrls: boolean = getSiteConfig(
8882
'includeNotionIdInUrls',

lib/notion.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import { mergeRecordMaps } from 'notion-utils'
55

66
import { notion } from './notion-api'
77
import { getPreviewImageMap } from './preview-images'
8-
import { getTweetAstMap } from './tweet-embeds'
98
import {
109
isPreviewImageSupportEnabled,
11-
isTweetEmbedSupportEnabled,
1210
navigationStyle,
1311
navigationLinks
1412
} from './config'
@@ -62,11 +60,6 @@ export async function getPage(pageId: string): Promise<ExtendedRecordMap> {
6260
;(recordMap as any).preview_images = previewImageMap
6361
}
6462

65-
if (isTweetEmbedSupportEnabled) {
66-
const tweetAstMap = await getTweetAstMap(recordMap)
67-
;(recordMap as any).tweetAstMap = tweetAstMap
68-
}
69-
7063
return recordMap
7164
}
7265

lib/tweet-embeds.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"next-api-og-image": "^2.2.1",
4040
"next-themes": "^0.1.1",
4141
"node-fetch": "^2.6.1",
42-
"notion-client": "^6.11.0",
42+
"notion-client": "^6.12.0",
4343
"notion-types": "^6.11.0",
4444
"notion-utils": "^6.11.0",
4545
"p-map": "^5.3.0",
@@ -49,9 +49,8 @@
4949
"react-body-classname": "^1.3.1",
5050
"react-dom": "^17.0.2",
5151
"react-notion-x": "^6.11.0",
52-
"react-static-tweets": "^0.7.2",
53-
"react-use": "^17.3.2",
54-
"static-tweets": "^0.7.2"
52+
"react-tweet-embed": "^2.0.0",
53+
"react-use": "^17.3.2"
5554
},
5655
"devDependencies": {
5756
"@next/bundle-analyzer": "^12.1.0",

pages/_app.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import 'react-notion-x/src/styles.css'
77
// used for rendering equations (optional)
88
import 'katex/dist/katex.min.css'
99

10-
// used for tweet embeds (optional)
11-
import 'react-static-tweets/styles.css'
12-
1310
// used for code syntax highlighting (optional)
1411
import 'prismjs/themes/prism-coy.css'
1512

pages/api/get-tweet-ast/[tweetId].ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)