mirror of
https://github.com/svemagie/obsidian-micropub.git
synced 2026-05-15 03:48:52 +02:00
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:
+8
-2
@@ -218,6 +218,8 @@ export class Publisher {
|
|||||||
props["visibility"] = [visibility];
|
props["visibility"] = [visibility];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
props["post-status"] = [(fm["post-status"] as string | undefined) ?? "draft"];
|
||||||
|
|
||||||
// AI disclosure — kebab-case keys (ai-text-level, ai-tools, etc.)
|
// AI disclosure — kebab-case keys (ai-text-level, ai-tools, etc.)
|
||||||
// with camelCase fallback for backward compatibility.
|
// with camelCase fallback for backward compatibility.
|
||||||
// Also support nested `ai` object flattening.
|
// Also support nested `ai` object flattening.
|
||||||
@@ -415,11 +417,16 @@ export class Publisher {
|
|||||||
":" +
|
":" +
|
||||||
String(now.getSeconds()).padStart(2, "0");
|
String(now.getSeconds()).padStart(2, "0");
|
||||||
|
|
||||||
|
const { frontmatter: fm } = this.parseFrontmatter(originalContent);
|
||||||
|
const wasDraft = fm["post-status"] !== "published";
|
||||||
|
|
||||||
const fields: Array<[string, string]> = [
|
const fields: Array<[string, string]> = [
|
||||||
["mp-url", `"${url}"`],
|
["mp-url", `"${url}"`],
|
||||||
["post-status", "published"],
|
|
||||||
["published", publishedDate],
|
["published", publishedDate],
|
||||||
];
|
];
|
||||||
|
if (!wasDraft) {
|
||||||
|
fields.push(["post-status", "published"]);
|
||||||
|
}
|
||||||
|
|
||||||
// Record the syndication targets used so future publishes know what was sent
|
// Record the syndication targets used so future publishes know what was sent
|
||||||
if (syndicateToOverride !== undefined) {
|
if (syndicateToOverride !== undefined) {
|
||||||
@@ -437,7 +444,6 @@ export class Publisher {
|
|||||||
|
|
||||||
// Stamp evergreen-since on first promotion to the evergreen garden stage.
|
// Stamp evergreen-since on first promotion to the evergreen garden stage.
|
||||||
{
|
{
|
||||||
const { frontmatter: fm } = this.parseFrontmatter(originalContent);
|
|
||||||
if (!fm["evergreen-since"]) {
|
if (!fm["evergreen-since"]) {
|
||||||
const rawTags = [
|
const rawTags = [
|
||||||
...this.resolveArray(fm["tags"]),
|
...this.resolveArray(fm["tags"]),
|
||||||
|
|||||||
Reference in New Issue
Block a user