mirror of
https://github.com/svemagie/obsidian-micropub.git
synced 2026-05-15 20:08:51 +02:00
fix: flatten ai object into scalar frontmatter properties
Sending ai as a wrapped Micropub array caused Indiekit to write a YAML array. The blog template reads aiTextLevel / aiCodeLevel as top-level scalar keys, not ai[0].textLevel. Flatten to individual properties so Indiekit writes them as plain strings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
main.js
|
|
||||||
data.json
|
data.json
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
|||||||
+12
-3
@@ -41,7 +41,9 @@ export class Publisher {
|
|||||||
|
|
||||||
// Determine if this is an update (post already has a URL) or new post
|
// Determine if this is an update (post already has a URL) or new post
|
||||||
const existingUrl: string | undefined =
|
const existingUrl: string | undefined =
|
||||||
frontmatter["mp-url"] ?? frontmatter["url"] ?? undefined;
|
frontmatter["mp-url"] != null ? String(frontmatter["mp-url"])
|
||||||
|
: frontmatter["url"] != null ? String(frontmatter["url"])
|
||||||
|
: undefined;
|
||||||
|
|
||||||
// Upload local images and rewrite markdown references
|
// Upload local images and rewrite markdown references
|
||||||
const { content: processedBody, uploadedUrls } =
|
const { content: processedBody, uploadedUrls } =
|
||||||
@@ -169,9 +171,16 @@ export class Publisher {
|
|||||||
props["visibility"] = [visibility];
|
props["visibility"] = [visibility];
|
||||||
}
|
}
|
||||||
|
|
||||||
// AI disclosure (custom property passed through to Indiekit)
|
// AI disclosure — flatten nested `ai` object into individual top-level
|
||||||
|
// properties so Indiekit writes them as plain scalar frontmatter keys.
|
||||||
|
// Sending `ai: [{textLevel: "1"}]` makes Indiekit write a YAML array,
|
||||||
|
// but the template reads `aiTextLevel` / `aiCodeLevel` as top-level scalars.
|
||||||
if (fm["ai"] && typeof fm["ai"] === "object") {
|
if (fm["ai"] && typeof fm["ai"] === "object") {
|
||||||
props["ai"] = [fm["ai"]];
|
const ai = fm["ai"] as Record<string, unknown>;
|
||||||
|
if (ai["textLevel"] != null) props["aiTextLevel"] = [String(ai["textLevel"])];
|
||||||
|
if (ai["codeLevel"] != null) props["aiCodeLevel"] = [String(ai["codeLevel"])];
|
||||||
|
if (ai["aiTools"] != null) props["aiTools"] = [String(ai["aiTools"])];
|
||||||
|
if (ai["aiDescription"] != null) props["aiDescription"] = [String(ai["aiDescription"])];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Photos: prefer structured photo array from frontmatter (with alt text),
|
// Photos: prefer structured photo array from frontmatter (with alt text),
|
||||||
|
|||||||
Reference in New Issue
Block a user