Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions PR.md
Original file line number Diff line number Diff line change
@@ -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`
13 changes: 13 additions & 0 deletions src/bases/groupTitleRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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, "");

Expand Down
Loading