#!/usr/bin/env node const { DateTime } = require("luxon"); const { loadArticles } = require("../lib/stats/articles"); async function computeMostProlificMonth(contentDir) { const articles = await loadArticles(contentDir); const counts = new Map(); for (const article of articles) { if (!article.date) continue; const monthKey = article.date.toFormat("yyyy-MM"); counts.set(monthKey, (counts.get(monthKey) || 0) + 1); } if (counts.size === 0) { return null; } const sorted = Array.from(counts.entries()).sort((a, b) => { if (b[1] !== a[1]) return b[1] - a[1]; return a[0] < b[0] ? -1 : 1; }); const [monthKey, count] = sorted[0]; const label = DateTime.fromISO(`${monthKey}-01`).setLocale("fr").toFormat("LLLL yyyy"); return { value: `${label} (${count})`, month: monthKey, count }; } async function run({ contentDir }) { const result = await computeMostProlificMonth(contentDir || "content"); return result || { value: null }; } module.exports = { run };