"use client"; import { Blog, HomelabApp } from "@/types"; import { useEffect, useState } from "react"; import { invoke } from "@tauri-apps/api/core"; import { useRouter } from "next/navigation"; interface BlogCardProps { blog: Blog & { linked_app_ids?: string[] }; } export default function BlogCard({ blog }: BlogCardProps) { const [referencedApps, setReferencedApps] = useState([]); const appIds = blog.linked_app_ids; const router = useRouter(); useEffect(() => { if (appIds && appIds.length > 0) { const fetchReferences = async () => { try { const apps = await invoke("get_apps_by_id", { ids: appIds, }); setReferencedApps(apps); } catch (err) { console.error("Failed to fetch referenced apps:", err); } }; fetchReferences(); } }, [appIds]); return (
router.push(`/write/edit?id=${blog.id}`)} > {/* Decorative background glow that triggers on hover */}
{/* Category / Meta indicator */} Homelab Log {/* Title */}

{blog.title}

{/* Truncated Tiptap HTML Content */}
{/* Footer / References */}
{!appIds || appIds.length === 0 ? ( No linked applications ) : ( referencedApps.map((app) => ( {/* App Avatar Placeholder (Uses first letter of app name) */} {app.name.charAt(0)} {app.name} )) )}
); }