fix: default post-status to draft; honor explicit published flag

- buildProperties() now sends post-status: draft by default when the
  frontmatter field is absent, so posts are never accidentally published
- Only post-status: published explicitly triggers a live publish
- writeUrlToNote() stamps post-status: published back only when the
  original note was already set to published
- Consolidate duplicate parseFrontmatter() call in writeUrlToNote()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
svemagie
2026-04-27 08:49:45 +02:00
parent b3288fcff0
commit 838dea6645
2 changed files with 13 additions and 7 deletions
+5 -5
View File
File diff suppressed because one or more lines are too long
+8 -2
View File
@@ -218,6 +218,8 @@ export class Publisher {
props["visibility"] = [visibility];
}
props["post-status"] = [(fm["post-status"] as string | undefined) ?? "draft"];
// AI disclosure — kebab-case keys (ai-text-level, ai-tools, etc.)
// with camelCase fallback for backward compatibility.
// Also support nested `ai` object flattening.
@@ -415,11 +417,16 @@ export class Publisher {
":" +
String(now.getSeconds()).padStart(2, "0");
const { frontmatter: fm } = this.parseFrontmatter(originalContent);
const wasDraft = fm["post-status"] !== "published";
const fields: Array<[string, string]> = [
["mp-url", `"${url}"`],
["post-status", "published"],
["published", publishedDate],
];
if (!wasDraft) {
fields.push(["post-status", "published"]);
}
// Record the syndication targets used so future publishes know what was sent
if (syndicateToOverride !== undefined) {
@@ -437,7 +444,6 @@ export class Publisher {
// Stamp evergreen-since on first promotion to the evergreen garden stage.
{
const { frontmatter: fm } = this.parseFrontmatter(originalContent);
if (!fm["evergreen-since"]) {
const rawTags = [
...this.resolveArray(fm["tags"]),