import React from 'react'; import Image from 'next/image'; import { useImageProxy } from '@/hooks/useImageProxy'; import { formatUnixTimestamp } from '@/utils/time'; import { Tag } from 'primereact/tag'; import { Message } from 'primereact/message'; import GenericButton from '@/components/buttons/GenericButton'; import useWindowWidth from '@/hooks/useWindowWidth'; import { BookOpen } from 'lucide-react'; import { highlightText, getTextWithMatchContext } from '@/utils/text'; const ContentDropdownItem = ({ content, onSelect }) => { const { returnImageProxy } = useImageProxy(); const windowWidth = useWindowWidth(); const isMobile = windowWidth <= 600; // Get match information if available const matches = content?._matches || {}; return (
onSelect(content)} >
content thumbnail

{matches.title ? highlightText( content?.title || content?.name, matches.title.term, 'bg-yellow-500/30 text-white font-bold px-0.5 rounded' ) : (content?.title || content?.name)}

{content?.price > 0 ? ( ) : ( )}
{content?.summary && (

{matches.description ? highlightText( getTextWithMatchContext(content.summary, matches.description.term, 60), matches.description.term, 'bg-yellow-500/30 text-white font-medium px-0.5 rounded' ) : content.summary}

)}
{content?.topics?.map(topic => ( ))}
{content?.published_at || content?.created_at ? `Published: ${formatUnixTimestamp(content?.published_at || content?.created_at)}` : 'Not yet published'}
{!isMobile && ( { e.stopPropagation(); onSelect(content); }} className="items-center py-1 shadow-sm hover:shadow-md transition-shadow duration-200" /> )}
); }; export default ContentDropdownItem;