eratic / sites / fav / src / content.config.ts
237 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 };

static mirror of HEAD · about · clone: git clone https://git.makefuture.ro/eratic.git