// Rendu des documents historiques longs (charte, orientation) en HTML.
// $lib/server → marked reste côté serveur ; pages prérendues, zéro coût client.
import { marked } from 'marked';

const files = import.meta.glob('/content/documents/*.md', {
	query: '?raw',
	import: 'default',
	eager: true
}) as Record<string, string>;

export function getDocument(nom: string): string {
	const key = `/content/documents/${nom}.md`;
	const raw = files[key];
	if (!raw) throw new Error(`Document introuvable : ${nom}`);
	return marked.parse(raw.trim(), { async: false }) as string;
}
