Skip to content

Commit 9fcb19c

Browse files
Merge pull request #273 from NotionX/feature/embed-tweets
2 parents c41d11c + 1dda2dc commit 9fcb19c

File tree

13 files changed

+34
-685
lines changed

13 files changed

+34
-685
lines changed

examples/cra/src/index.tsx

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

14-
// used for tweet embeds (optional)
15-
// import 'react-static-tweets/styles.css'
16-
1714
import './index.css'
1815

1916
ReactDOM.render(

examples/full/components/NotionPage.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useRouter } from 'next/router'
88
import { NotionRenderer } from 'react-notion-x'
99
import { ExtendedRecordMap } from 'notion-types'
1010
import { getPageTitle } from 'notion-utils'
11-
import { Tweet, TwitterContextProvider } from 'react-static-tweets'
11+
import TweetEmbed from 'react-tweet-embed'
1212

1313
import { Loading } from './Loading'
1414

@@ -76,6 +76,10 @@ const Modal = dynamic(
7676
}
7777
)
7878

79+
const Tweet = ({ id }: { id: string }) => {
80+
return <TweetEmbed tweetId={id} />
81+
}
82+
7983
export const NotionPage = ({
8084
recordMap,
8185
previewImagesEnabled,
@@ -114,15 +118,7 @@ export const NotionPage = ({
114118
'https://react-notion-x-demo.transitivebullsh.it/social.jpg'
115119

116120
return (
117-
<TwitterContextProvider
118-
value={{
119-
tweetAstMap: (recordMap as any).tweetAstMap || {},
120-
swrOptions: {
121-
fetcher: (id: string) =>
122-
fetch(`/api/get-tweet-ast/${id}`).then((r) => r.json())
123-
}
124-
}}
125-
>
121+
<>
126122
<Head>
127123
{socialDescription && (
128124
<>
@@ -170,6 +166,6 @@ export const NotionPage = ({
170166
// NOTE: custom images will only take effect if previewImages is true and
171167
// if the image has a valid preview image defined in recordMap.preview_images[src]
172168
/>
173-
</TwitterContextProvider>
169+
</>
174170
)
175171
}

examples/full/lib/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ export const rootNotionSpaceId = 'fde5ac74-eea3-4527-8f00-4482710e1af3'
99
// you cache the preview image results in a key-value database.
1010
export const previewImagesEnabled = true
1111

12-
// whether we should enable static tweet embeds (requires fetching extra info at
13-
// build time)
14-
export const tweetEmbedsEnabled = true
15-
1612
// Whether to use the official public Notion API or the unofficial private API.
1713
// Note that the official API doesn't expose formatting options for many blocks
1814
// and is currently not as well-supported.

examples/full/lib/notion.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ import { NotionAPI } from 'notion-client'
44
import { ExtendedRecordMap, SearchParams, SearchResults } from 'notion-types'
55

66
import { getPreviewImageMap } from './preview-images'
7-
import { getTweetAstMap } from './tweet-embeds'
8-
import {
9-
useOfficialNotionAPI,
10-
previewImagesEnabled,
11-
tweetEmbedsEnabled
12-
} from './config'
7+
import { useOfficialNotionAPI, previewImagesEnabled } from './config'
138

149
const notion = useOfficialNotionAPI
1510
? new NotionCompatAPI(new Client({ auth: process.env.NOTION_TOKEN }))
@@ -29,11 +24,6 @@ export async function getPage(pageId: string): Promise<ExtendedRecordMap> {
2924
;(recordMap as any).preview_images = previewImageMap
3025
}
3126

32-
if (tweetEmbedsEnabled) {
33-
const tweetAstMap = await getTweetAstMap(recordMap)
34-
;(recordMap as any).tweetAstMap = tweetAstMap
35-
}
36-
3727
return recordMap
3828
}
3929

examples/full/lib/tweet-embeds.ts

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

examples/full/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@notionhq/client": "^1.0.4",
17+
"classnames": "^2.3.1",
1718
"got": "^12.0.2",
1819
"lqip-modern": "^1.2.0",
1920
"next": "^12.1.0",
@@ -25,8 +26,7 @@
2526
"react": "^17.0.2",
2627
"react-dom": "^17.0.2",
2728
"react-notion-x": "^6.11.0",
28-
"react-static-tweets": "^0.7.1",
29-
"static-tweets": "^0.7.1"
29+
"react-tweet-embed": "^2.0.0"
3030
},
3131
"devDependencies": {
3232
"@next/bundle-analyzer": "^12.1.0",

examples/full/pages/_app.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import 'prismjs/themes/prism-tomorrow.css'
1111
// used for rendering equations (optional)
1212
import 'katex/dist/katex.min.css'
1313

14-
// used for tweet embeds (optional)
15-
import 'react-static-tweets/styles.css'
16-
1714
function MyApp({ Component, pageProps }) {
1815
return <Component {...pageProps} />
1916
}

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

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

examples/full/readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ This demo adds a few nice features:
1414

1515
- Uses [next/image](https://nextjs.org/docs/api-reference/next/image) to serve optimal images
1616
- Uses preview images generated using [lqip-modern](https://github.com/transitive-bullshit/lqip-modern)
17-
- Embeds tweets via [react-static-tweets](https://github.com/transitive-bullshit/react-static-tweets)
1817
- Includes larger optional components via [next/dynamic](https://nextjs.org/docs/advanced-features/dynamic-import)
1918
- Collection, CollectionRow
2019
- Code

examples/minimal/pages/_app.tsx

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

14-
// used for tweet embeds (optional)
15-
// import 'react-static-tweets/styles.css'
16-
1714
function MyApp({ Component, pageProps }) {
1815
return <Component {...pageProps} />
1916
}

0 commit comments

Comments
 (0)