import Link from "next/link"; import Image from "next/image"; import { Music } from "lucide-react"; import { api } from "@/lib/api"; import { Artist, DiscoverResult } from "../types"; interface TopResultProps { libraryArtist?: Artist; discoveryArtist?: DiscoverResult; } export function TopResult({ libraryArtist, discoveryArtist }: TopResultProps) { // Prefer library artist over discovery if (!libraryArtist && !discoveryArtist) { return null; } const isLibrary = !!libraryArtist; // Get the display name const name = libraryArtist?.name || discoveryArtist?.name || ""; // Get the artist ID for linking - prefer MBID for consistent URLs const artistId = isLibrary ? libraryArtist!.mbid || libraryArtist!.id : discoveryArtist?.mbid || encodeURIComponent(name); // Get the image URL const imageUrl = isLibrary ? libraryArtist?.heroUrl : discoveryArtist?.image; return (

Top result

{imageUrl ? ( {name} ) : ( )}

{name}

Artist

); }