feat: add evergreen to GardenStage type and labels

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
svemagie
2026-03-15 08:45:48 +01:00
parent 6abd6ce4ba
commit fa53528137
2 changed files with 25 additions and 11 deletions
+23 -11
View File
@@ -139,7 +139,7 @@ export class Publisher {
// Categories from frontmatter `category` or `tags` (excluding garden/* tags)
const rawTags = this.resolveArray(fm["tags"] ?? fm["category"]);
const gardenStage = this.extractGardenStage(rawTags);
const gardenStageFromTags = this.extractGardenStage(rawTags);
const normalTags = rawTags.filter(
(t) => !t.startsWith(GARDEN_TAG_PREFIX) && t !== "garden",
);
@@ -147,9 +147,16 @@ export class Publisher {
props["category"] = normalTags;
}
// Garden stage → dedicated property
if (this.settings.mapGardenTags && gardenStage) {
props["garden-stage"] = [gardenStage];
// Garden stage — prefer explicit `gardenStage` frontmatter property,
// fall back to extracting from #garden/* tags.
// Send as camelCase `gardenStage` so Indiekit writes it directly to
// frontmatter without needing a preset property mapping for `garden-stage`.
if (this.settings.mapGardenTags) {
const gardenStage =
(fm["gardenStage"] as string | undefined) ?? gardenStageFromTags;
if (gardenStage) {
props["gardenStage"] = [gardenStage];
}
}
// Syndication targets
@@ -173,15 +180,20 @@ export class Publisher {
// AI disclosure — flatten nested `ai` object into individual top-level
// properties so Indiekit writes them as plain scalar frontmatter keys.
// Also support top-level `aiTextLevel`, `aiTools`, etc. set directly.
// 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") {
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"])];
}
const aiObj = (fm["ai"] && typeof fm["ai"] === "object")
? fm["ai"] as Record<string, unknown>
: {};
const aiTextLevel = fm["aiTextLevel"] ?? aiObj["textLevel"];
const aiCodeLevel = fm["aiCodeLevel"] ?? aiObj["codeLevel"];
const aiTools = fm["aiTools"] ?? aiObj["aiTools"] ?? aiObj["tools"];
const aiDescription = fm["aiDescription"] ?? aiObj["aiDescription"] ?? aiObj["description"];
if (aiTextLevel != null) props["aiTextLevel"] = [String(aiTextLevel)];
if (aiCodeLevel != null) props["aiCodeLevel"] = [String(aiCodeLevel)];
if (aiTools != null) props["aiTools"] = [String(aiTools)];
if (aiDescription != null) props["aiDescription"] = [String(aiDescription)];
// Photos: prefer structured photo array from frontmatter (with alt text),
// fall back to uploaded local images.
+2
View File
@@ -105,6 +105,7 @@ export interface MicropubConfig {
export type GardenStage =
| "plant"
| "cultivate"
| "evergreen"
| "question"
| "repot"
| "revitalize"
@@ -113,6 +114,7 @@ export type GardenStage =
export const GARDEN_STAGE_LABELS: Record<GardenStage, string> = {
plant: "🌱 Seedling",
cultivate: "🌿 Growing",
evergreen: "🌳 Evergreen",
question: "❓ Open Question",
repot: "🪴 Repotting",
revitalize: "✨ Revitalizing",