From 7a39adcbb0e17d072a526680aceb2e4e0bd686fe Mon Sep 17 00:00:00 2001 From: Logan Yang Date: Tue, 31 Dec 2024 18:55:44 -0800 Subject: [PATCH] Fix tags in indexing filter (#988) --- src/utils.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index c83cc7ef..f94b1923 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -87,9 +87,11 @@ export async function getTagsFromNote(file: TFile, vault: Vault): Promise tag.replace("#", "")) + // Handle both array and string formats of tags + const normalizedTags = Array.isArray(tags) ? tags : [tags]; + // Strip any '#' from the frontmatter tags and convert to lowercase + return normalizedTags + .map((tag: string) => tag.toString().replace(/^#/, "")) .map((tag: string) => tag.toLowerCase()); } catch (error) { console.error("Error parsing YAML frontmatter:", error); @@ -109,8 +111,8 @@ export async function getNotesFromTags( return []; } - // Strip any '#' from the tags set from the user - tags = tags.map((tag) => tag.replace("#", "")); + // Strip any '#' from the tags and convert to lowercase for consistent comparison + tags = tags.map((tag) => tag.replace(/^#/, "").toLowerCase()); const files = noteFiles && noteFiles.length > 0 ? noteFiles : await getNotesFromPath(vault, "/"); const filesWithTag = [];