mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 15:09:47 +00:00
feat: improve tweet embedding using react-tweet
This commit is contained in:
@@ -7,8 +7,12 @@ import { type PageBlock } from 'notion-types'
|
||||
import { formatDate, getBlockTitle, getPageProperty } from 'notion-utils'
|
||||
import * as React from 'react'
|
||||
import BodyClassName from 'react-body-classname'
|
||||
import { type NotionComponents, NotionRenderer } from 'react-notion-x'
|
||||
import TweetEmbed from 'react-tweet-embed'
|
||||
import {
|
||||
type NotionComponents,
|
||||
NotionRenderer,
|
||||
useNotionContext
|
||||
} from 'react-notion-x'
|
||||
import { EmbeddedTweet, TweetNotFound, TweetSkeleton } from 'react-tweet'
|
||||
import { useSearchParam } from 'react-use'
|
||||
|
||||
import type * as types from '@/lib/types'
|
||||
@@ -97,7 +101,14 @@ const Modal = dynamic(
|
||||
)
|
||||
|
||||
function Tweet({ id }: { id: string }) {
|
||||
return <TweetEmbed tweetId={id} />
|
||||
const { recordMap } = useNotionContext()
|
||||
const tweet = (recordMap as types.ExtendedTweetRecordMap)?.tweets?.[id]
|
||||
|
||||
return (
|
||||
<React.Suspense fallback={<TweetSkeleton />}>
|
||||
{tweet ? <EmbeddedTweet tweet={tweet} /> : <TweetNotFound />}
|
||||
</React.Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
const propertyLastEditedTimeValue = (
|
||||
|
||||
Reference in New Issue
Block a user