Files
brain/tools/secretary-index.mjs
T

11 lines
534 B
JavaScript

// Апсерт строки дела в оглавление (§D8). Ключ — <slug>/protocol.md.
export function upsertIndexEntry(indexMd, { slug, title, goal, status, date }) {
const line = `- [${title}](${slug}/protocol.md) — ${goal} · ${status} · ${date}`;
const key = `(${slug}/protocol.md)`;
const lines = String(indexMd || '').split('\n').filter((l) => l.length > 0);
const idx = lines.findIndex((l) => l.includes(key));
if (idx >= 0) lines[idx] = line;
else lines.push(line);
return lines.join('\n');
}