Fix Face artifact title link matching

This commit is contained in:
Meta Vens 2026-05-26 20:23:09 +01:00
commit 59932c41bb
3 changed files with 9 additions and 6 deletions

View file

@ -73,11 +73,13 @@ function findMentionedKnowledgebaseDocument(
const normalizedContent = normalizeReferenceText(content);
const markdownDocuments = documents
.filter((document) => document.path.toLowerCase().endsWith(".md"))
.map((document) => ({
document,
label: document.title?.trim() || basenameWithoutExtension(document.path),
}))
.filter((entry) => entry.label.length >= 10)
.flatMap((document) =>
[...new Set([
document.title?.trim(),
basenameWithoutExtension(document.path),
].filter((label): label is string => Boolean(label && label.length >= 10)))]
.map((label) => ({ document, label }))
)
.sort((left, right) => right.label.length - left.label.length);
return markdownDocuments.find((entry) =>