import { getCollection, type CollectionEntry } from 'astro:content';

export type FindsPost = CollectionEntry<'finds'>;

export async function findsReferencing(slug: string): Promise<FindsPost[]> {
  const all = await getCollection('finds');
  return all
    .filter((p) => p.data.items.includes(slug))
    .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
}
