diff --git a/PR.md b/PR.md new file mode 100644 index 00000000..b45e3702 --- /dev/null +++ b/PR.md @@ -0,0 +1,27 @@ +# fix/context-group-title + +## Context Group Header Rendering + +Prevent group headers from resolving plain strings as file links. Only explicit links or values that look like file paths are resolved, so context values like "STY" stay intact. + +Examples (illustrative): + +- Current: contexts = "STY" and a file `sty.md` exists with `title: Foo` -> header shows "Foo" (linked). +- Target: contexts = "STY" always shows "STY" as plain text. + +## Changelog + +- Treat non-link, non-path group titles as plain text. +- Keep file link rendering for explicit wiki/markdown links and path-like values. + +## Tests + +- `npm run i18n:sync` +- `npm run lint` (warnings only; matches upstream) +- `node generate-release-notes-import.mjs` +- `npm run typecheck` +- `npm run test:ci -- --verbose` (fails: `due-date-timezone-inconsistency.test.ts`, also failing in upstream) +- `npm run test:integration` +- `npm run test:performance` +- `npm run build` (warns about missing OAuth env vars) +- `npm run test:build` diff --git a/src/bases/groupTitleRenderer.ts b/src/bases/groupTitleRenderer.ts index 4280772c..b326067e 100644 --- a/src/bases/groupTitleRenderer.ts +++ b/src/bases/groupTitleRenderer.ts @@ -2,6 +2,14 @@ import { parseLinktext, TFile } from "obsidian"; import { appendInternalLink, type LinkServices } from "../ui/renderers/linkRenderer"; import { parseLinkToPath } from "../utils/linkUtils"; +function looksLikeFilePath(value: string): boolean { + const trimmed = value.trim(); + if (trimmed.length === 0) return false; + if (trimmed.startsWith("./") || trimmed.startsWith("../")) return true; + if (trimmed.includes("/") || trimmed.includes("\\")) return true; + return trimmed.endsWith(".md"); +} + function resolveDisplayText( filePath: string, displayText: string, @@ -87,6 +95,11 @@ export function renderGroupTitle( // Check if title is a file path (with or without .md extension) // Try to resolve it as a file + if (!looksLikeFilePath(title)) { + container.textContent = title; + return; + } + const filePathToTry = title.endsWith(".md") ? title.replace(/\.md$/, "") : title; const file = linkServices.metadataCache.getFirstLinkpathDest(filePathToTry, "");