'use client'; import { useEffect, useState } from 'react'; import { clsx } from 'clsx/lite'; import Link from 'next/link'; import { BiError } from 'react-icons/bi'; import Spinner from '@/components/Spinner'; import { IMAGE_OG_DIMENSION } from '../image-response'; export type OGLoadingState = 'unloaded' | 'loading' | 'loaded' | 'failed'; export default function OGTile({ title, description, path, pathImageAbsolute, loadingState: loadingStateExternal, riseOnHover, onLoad, onFail, retryTime, }: { title: string description: string path: string pathImageAbsolute: string loadingState?: OGLoadingState onLoad?: () => void onFail?: () => void riseOnHover?: boolean retryTime?: number }) { const [loadingStateInternal, setLoadingStateInternal] = useState(loadingStateExternal ?? 'unloaded'); const loadingState = loadingStateExternal ?? loadingStateInternal; useEffect(() => { if ( !loadingStateExternal && loadingStateInternal === 'unloaded' ) { setLoadingStateInternal('loading'); } }, [loadingStateExternal, loadingStateInternal]); const { width, height, aspectRatio } = IMAGE_OG_DIMENSION; return (