diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index fff6dcb..9d72614 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -26,6 +26,10 @@ export const getTagMeta = (tag: string): TagMeta => { return { main, sub } } +export const retrieveTag = (tagMeta: TagMeta): string => { + return tagMeta.main ? tagMeta.main : tagMeta.sub ? tagMeta.sub : '' +} + export const mapLinkMeta = (linkMeta: LinkMeta[]) => { const map = new Map() for (const link of linkMeta) map.set(link.filePath, link) diff --git a/src/utils/tasks.ts b/src/utils/tasks.ts index 5b423a4..e95dddd 100644 --- a/src/utils/tasks.ts +++ b/src/utils/tasks.ts @@ -15,6 +15,7 @@ import { getFrontmatterTags, getIndentationSpacesFromTodoLine, getTagMeta, + retrieveTag, lineIsValidTodo, mapLinkMeta, removeTagFromText, @@ -58,12 +59,12 @@ export const parseTodos = async ( if (todoTags.length === 1 && todoTags[0] === "*") return true const fileCache = cache.getFileCache(file) const allTags = getAllTagsFromMetadata(fileCache) - const tagsOnPage = allTags.filter((tag) => todoTags.includes(getTagMeta(tag).main.toLowerCase())) + const tagsOnPage = allTags.filter((tag) => todoTags.includes(retrieveTag(getTagMeta(tag)).toLowerCase())) return tagsOnPage.length > 0 }) .map>(async (file) => { const fileCache = cache.getFileCache(file) - const tagsOnPage = fileCache?.tags?.filter((e) => todoTags.includes(getTagMeta(e.tag).main.toLowerCase())) ?? [] + const tagsOnPage = fileCache?.tags?.filter((e) => todoTags.includes(retrieveTag(getTagMeta(e.tag)).toLowerCase())) ?? [] const frontMatterTags = getFrontmatterTags(fileCache, todoTags) const hasFrontMatterTag = frontMatterTags.length > 0 const parseEntireFile = todoTags[0] === "*" || hasFrontMatterTag || showAllTodos