'use client'; import Link from 'next/link'; import { type Post } from 'contentlayer/generated'; import Balancer from 'react-wrap-balancer'; import { useSearchStore } from '@/stores/search-store'; import { formatDateTime } from '@/lib/datetime'; import { cn } from '@/lib/utils'; type SearchResultsProps = { query: string; results: Post[]; }; export function SearchResults({ query, results }: SearchResultsProps) { const toggleSearch = useSearchStore((state) => state.toggleSearch); return ( ); } /** * Highlights the search query in the text by wrapping it in a span with the * font-extrabold class. * @param query The search query * @param text The text to highlight * @returns The text with the query highlighted */ function highlightSearchQuery(query: string, text: string) { const sanitizedQuery = query.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); return text.split(new RegExp(`(${sanitizedQuery})`, 'gi')).map((part, i) => ( {part} )); }