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:
svemagie
2026-03-14 18:36:13 +01:00
parent b790a98488
commit 6abd6ce4ba
3 changed files with 29 additions and 4 deletions
-1
View File
@@ -1,4 +1,3 @@
node_modules
main.js
data.json
package-lock.json
+17
View File
File diff suppressed because one or more lines are too long
+12 -3
View File
@@ -41,7 +41,9 @@ export class Publisher {
// Determine if this is an update (post already has a URL) or new post
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
const { content: processedBody, uploadedUrls } =
@@ -169,9 +171,16 @@ export class Publisher {
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") {
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),