bb7633b318
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
11 lines
534 B
JavaScript
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');
|
|
}
|