import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';
import { baseEntry, themeOverride } from '@eratic/core';
/**
* fav.eratic.ro — one collection, five kinds.
*
* src/content/favs/2026/the-glass-bead-game.mdx → /2026/the-glass-bead-game/
*
* `kind` drives the listing filters (/books/, /films/, …) and the label under
* each item. `creator` is deliberately one loose field rather than
* author/director/artist/maker: they all mean "whose thing is this", and four
* near-identical optional fields is exactly the sort of schema that makes you
* stop posting.
*/
export const KINDS = ['object', 'book', 'film', 'music', 'other'] as const;
export type Kind = (typeof KINDS)[number];
/** Plural, for headings and URLs. */
export const KIND_PLURAL: Record<Kind, string> = {
object: 'objects',
book: 'books',
film: 'films',
music: 'music',
other: 'other',
};
const favs = defineCollection({
loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: './src/content/favs' }),
schema: ({ image }) =>
baseEntry.extend({
kind: z.enum(KINDS),
/** Author, director, band, maker, studio — whoever made it. */
creator: z.string().optional(),
/** Year the thing was made, not the year you found it. */
year: z.number().int().min(0).max(2999).optional(),
/** Where to find it. Never an affiliate link. */
link: z.url().optional(),
/**
* Optional, and genuinely optional — plenty of things are worth
* writing about without being scored. Omit it and nothing renders.
*/
rating: z.number().int().min(1).max(5).optional(),
cover: image().optional(),
coverAlt: z.string().optional(),
canvas: z.enum(['article', 'wide', 'bare']).default('article'),
theme: themeOverride,
}),
});
export const collections = { favs };