import { LinkPreview } from "@astro-community/astro-embed-link-preview";
import { YouTube } from "@astro-community/astro-embed-youtube";
import { BlueskyPost } from "@astro-community/astro-embed-bluesky";
import { Vimeo } from "@astro-community/astro-embed-vimeo";
import X from "./X.astro";
import Bilibili from "./Bilibili.astro";
import Tiktok from "./Tiktok.astro";
const { href, title } = Astro.props as Props;
type EmbedProps = Readonly<{
type EmbedComponent = (props: EmbedProps) => any;
{ match: /twitter\.com|x\.com/, Comp: X },
{ match: /youtube\.com|youtu\.be/, Comp: YouTube },
{ match: /vimeo\.com/, Comp: Vimeo },
{ match: /bsky\.app/, Comp: BlueskyPost },
{ match: /bilibili\.com/, Comp: Bilibili },
{ match: /tiktok\.com/, Comp: Tiktok },
] satisfies readonly EmbedRule[];
function resolveEmbed(href: string): EmbedComponent | null {
for (const { match, Comp } of rules) {
if (match.test(href)) return Comp;
const Comp = resolveEmbed(href);
{Comp ? <Comp id={href} /> : <LinkPreview id={href} />}