diff --git a/src/components/journal/types/spark.tsx b/src/components/journal/types/spark.tsx index c51fc41..20542ea 100644 --- a/src/components/journal/types/spark.tsx +++ b/src/components/journal/types/spark.tsx @@ -13,16 +13,10 @@ */ import { z } from "zod"; -import { Show, For } from "solid-js"; +import { For } from "solid-js"; import { registerMessageType } from "../registry"; import { rollFormula } from "../../md-commander/hooks"; -import { - findSparkTable, - rollSparkTable, - parseMarkdownTables, - isSparkTable, - sparkTableSlug, -} from "../../utils/spark-table"; +import { findSparkTable, rollSparkTable } from "../../utils/spark-table"; import { getIndexedData } from "../../../data-loader/file-index"; // --------------------------------------------------------------------------- @@ -78,9 +72,16 @@ export async function resolveSparkPayload(raw: { key: string; filePath: string; }): Promise { - // key is "pageName-columnSlug"; columnSlug is the part after the first "-" - const dashIdx = raw.key.indexOf("-"); - const columnSlug = dashIdx === -1 ? raw.key : raw.key.slice(dashIdx + 1); + // key is "pageName-columnSlug". The page name is the last segment of + // filePath (e.g. "01-dry-dock" from "/ayi-games/.../01-dry-dock"). + // Strip it from the key to recover the column slug. + const pathParts = raw.filePath.replace(/^\//, "").split("/"); + const pageName = pathParts[pathParts.length - 1] || raw.filePath; + const columnSlug = + raw.key.length > pageName.length + 1 && raw.key.startsWith(pageName + "-") + ? raw.key.slice(pageName.length + 1) + : raw.key; + const filePath = `/${raw.filePath.replace(/^\//, "")}`; let content: string;