feat: use custom tweet api

This commit is contained in:
DIYgod
2023-08-21 21:47:38 +01:00
parent c84e090011
commit 3b67ccc01c
2 changed files with 35 additions and 3 deletions
+9 -3
View File
@@ -1,10 +1,12 @@
import dynamic from "next/dynamic"
import Image from "next/image"
import type { TweetComponents } from "react-tweet"
import type { TwitterComponents } from "react-tweet"
import { SITE_URL } from "~/lib/env"
const ReactTweet = dynamic(async () => (await import("react-tweet")).Tweet)
const components: TweetComponents = {
const components: TwitterComponents = {
AvatarImg: (props) => <Image {...props} alt="avatar" />,
MediaImg: (props) => <Image {...props} fill unoptimized alt="tweet-media" />,
}
@@ -12,7 +14,11 @@ const components: TweetComponents = {
export default function Tweet({ id }: { id: string }) {
return (
<div className="flex justify-center">
<ReactTweet id={id} components={components} />
<ReactTweet
id={id}
components={components}
apiUrl={`${SITE_URL}/api/tweet?id=${id}`}
/>
</div>
)
}