--- import type { SocialData } from "../cache_fetch/deps/social_data"; import { resolveProps, textColorBasedOnBackgroundColor, bgColorHexFromClasses, type CoreProps } from "../astro"; import type { CacheOptions } from "../cache_fetch/deps/cache"; import Embed from "./Embed.astro"; export type CardProps = { large?: boolean; noImage?: boolean; noTheme?: boolean; small?: boolean; useIcon?: boolean; } export type CustomProps = CacheOptions & CardProps & CoreProps; export type Props = CustomProps & Omit, "url">; const props = resolveProps(Astro.props); const cacheFetchOptions = { clear: props.clear, prevent: props.prevent, }; let { className, description, domain, icon, image, large, noImage, noTheme, size, small, title, url, useIcon, } = props; let optionalSize: string | undefined = size const themeColor = bgColorHexFromClasses(className) || props.themeColor || "#fff"; const bgColor = noTheme !== true && themeColor && `background-color: ${themeColor}`; const textColor = noTheme !== true && themeColor && `color: ${textColorBasedOnBackgroundColor(themeColor)}`; image = useIcon ? icon : image || icon; if (small) optionalSize = "small"; if (large) optionalSize = "large"; const style = [bgColor, textColor].filter(Boolean).join(" ;"); const useSimple = !image && (!title || title === domain) && !description; if (useSimple) { title = url; optionalSize = undefined; } if (noImage) { optionalSize = undefined; } --- {(() => { const small = (
{image && (
)}

{domain}

{title &&

{title.substring(0, 100)}

} {description && (

{description.substring(0, 200)}

)}
); const withoutImage = (

{domain}

{title &&

{title}

} {description && (

{description}

)}
); const large = ( {image && ( )} {withoutImage} ); if (optionalSize === 'small') return small; if (optionalSize === 'large') return large; return withoutImage; })()}