package file→ .shtukbase/packages/content/checks/c02_draft.ts
checks/c02_draft.ts
21 lines, 1.4 KB.
- // CNT-R02. A draft rests on an idea and a platform that exist; the idea is approved or drafted; the platform is not
- // paused (published drafts keep their platform even when it is paused later).
- import { FOLDERS, exists, page, phase, records, ref, report, text } from '../lib/content.ts';
- const out: string[] = [];
- const drafts = records(FOLDERS.drafts);
- for (const r of drafts) {
- const idea = ref(r.fm.idea, r.id);
- if (!idea) out.push(`${r.id}: no link to an idea → write idea: /content/ideas/<name> [no-idea]`);
- else if (!exists(idea)) out.push(`${r.id}: idea ${idea} does not exist → fix the link [missing-idea]`);
- else {
- const st = phase(page(idea).fm.status);
- if (!['approved', 'drafted'].includes(st)) out.push(`${r.id}: idea ${idea} is in the state "${st || '—'}", not approved → a person approves the idea, or remove the draft [idea-not-approved]`);
- }
- const pl = ref(r.fm.platform, r.id);
- if (!pl) out.push(`${r.id}: no platform → write platform: /content/platforms/<name> [no-platform]`);
- else if (!exists(pl)) out.push(`${r.id}: platform ${pl} does not exist → fix the link [missing-platform]`);
- else if (text(page(pl).fm.status) === 'paused' && phase(r.fm.status) !== 'published')
- out.push(`${r.id}: platform ${pl} is paused → take another platform or lift the pause [platform-paused]`);
- }
- report(out, `drafts (${drafts.length})`);