--- import { parseOpenGraph } from "./lib"; import type { HTMLAttributes } from "astro/types"; export type Props = HTMLAttributes<"a"> & { showMedia?: boolean; showDescription?: boolean; showTitle?: boolean; showDomain?: boolean; showGradient?: boolean; blurMedia?: boolean; id?: string; title?: string; description?: string; }; const { href, id, class: className, showDescription = false, showTitle = true, showDomain = true, showMedia = true, showGradient = true, target = "_blank", title, description, ...props } = Astro.props; const meta = await parseOpenGraph((href ?? id)?.toString() ?? ""); if (title && meta) meta.title = title; if (description && meta) meta.description = description; const domain = meta?.url ? new URL(meta.url).hostname.replace("www.", "") : ""; ---
{ !showMedia ? null : meta?.video && meta.videoType ? ( ) : meta?.image ? ( {meta.imageAlt ) : null } { showGradient ? (
) : null } { showDomain ? (
{domain ?? ""}
) : null } { showDescription ? (
{meta?.description ?? ""}
) : null }