Revert "feat: remove tweet embeding"

This reverts commit 7fcb61fd5f.
This commit is contained in:
DIYgod
2024-01-14 11:32:03 +08:00
parent b48a3807ea
commit 3edf43af7c
5 changed files with 73 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import dynamic from "next/dynamic"
import Image from "next/image"
import type { TwitterComponents } from "react-tweet"
import { SITE_URL } from "~/lib/env"
const ReactTweet = dynamic(async () => (await import("react-tweet")).Tweet)
const components: TwitterComponents = {
AvatarImg: (props) => <Image {...props} alt="avatar" />,
MediaImg: (props) => <Image {...props} fill unoptimized alt="tweet-media" />,
}
export default function Tweet({ id }: { id: string }) {
return (
<div className="flex justify-center">
<ReactTweet
id={id}
components={components}
apiUrl={`${SITE_URL}/api/tweet?id=${id}`}
/>
</div>
)
}