From 9e719a7b53742a80be3a1adc14889472032d192e Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Sun, 17 Apr 2022 15:04:08 +0200 Subject: [PATCH] feat: :sparkles: `BC-ignore: true` to ignore a note from BC entirely --- src/AlternativeHierarchies/DataviewNotes.ts | 3 +- src/AlternativeHierarchies/DendronNotes.ts | 4 +- src/AlternativeHierarchies/FolderNotes.ts | 3 +- src/AlternativeHierarchies/RegexNotes.ts | 3 +- src/AlternativeHierarchies/TagNotes.ts | 3 +- src/constants.ts | 48 +++++++++++---------- 6 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/AlternativeHierarchies/DataviewNotes.ts b/src/AlternativeHierarchies/DataviewNotes.ts index 94303c38..5747fea5 100644 --- a/src/AlternativeHierarchies/DataviewNotes.ts +++ b/src/AlternativeHierarchies/DataviewNotes.ts @@ -1,7 +1,7 @@ import type { MultiGraph } from "graphology"; import { warn } from "loglevel"; import { Notice } from "obsidian"; -import { BC_DV_NOTE, BC_DV_NOTE_FIELD, DATAVIEW_MISSING } from "../constants"; +import { BC_DV_NOTE, BC_DV_NOTE_FIELD, BC_IGNORE, DATAVIEW_MISSING } from "../constants"; import type { dvFrontmatterCache } from "../interfaces"; import type BCPlugin from "../main"; import { @@ -44,6 +44,7 @@ export function addDataviewNotesToGraph( } for (const target of targets) { + if (target[BC_IGNORE]) continue; const targetBN = getDVBasename(target.file); const sourceOrder = getSourceOrder(altFile); const targetOrder = getTargetOrder(frontms, targetBN); diff --git a/src/AlternativeHierarchies/DendronNotes.ts b/src/AlternativeHierarchies/DendronNotes.ts index c6f393d8..5205b8b8 100644 --- a/src/AlternativeHierarchies/DendronNotes.ts +++ b/src/AlternativeHierarchies/DendronNotes.ts @@ -1,5 +1,5 @@ import type { MultiGraph } from "graphology"; -import { BC_IGNORE_DENDRON } from "../constants"; +import { BC_IGNORE, BC_IGNORE_DENDRON } from "../constants"; import type { dvFrontmatterCache } from "../interfaces"; import type BCPlugin from "../main"; import { @@ -22,7 +22,7 @@ export function addDendronNotesToGraph( if (!addDendronNotes) return; for (const frontm of frontms) { - if (frontm[BC_IGNORE_DENDRON]) continue; + if (frontm[BC_IGNORE_DENDRON] || frontm[BC_IGNORE]) continue; let curr = getDVBasename(frontm.file); let parent = getDendronParent(curr, dendronNoteDelimiter); diff --git a/src/AlternativeHierarchies/FolderNotes.ts b/src/AlternativeHierarchies/FolderNotes.ts index 65af45ef..ed4a0784 100644 --- a/src/AlternativeHierarchies/FolderNotes.ts +++ b/src/AlternativeHierarchies/FolderNotes.ts @@ -4,6 +4,7 @@ import { BC_FOLDER_NOTE, BC_FOLDER_NOTE_RECURSIVE, BC_FOLDER_NOTE_SUBFOLDERS, + BC_IGNORE, } from "../constants"; import type { dvFrontmatterCache } from "../interfaces"; import type BCPlugin from "../main"; @@ -45,7 +46,7 @@ export function addFolderNotesToGraph( .map((ff) => ff.file) .filter( (other) => - getFolderName(other) === topFolderName && other.path !== file.path + getFolderName(other) === topFolderName && other.path !== file.path && !other[BC_IGNORE] ) .map(getDVBasename); diff --git a/src/AlternativeHierarchies/RegexNotes.ts b/src/AlternativeHierarchies/RegexNotes.ts index bed554dc..71990318 100644 --- a/src/AlternativeHierarchies/RegexNotes.ts +++ b/src/AlternativeHierarchies/RegexNotes.ts @@ -1,6 +1,6 @@ import type { MultiGraph } from "graphology"; import { info } from "loglevel"; -import { BC_REGEX_NOTE, BC_REGEX_NOTE_FIELD } from "../constants"; +import { BC_IGNORE, BC_REGEX_NOTE, BC_REGEX_NOTE_FIELD } from "../constants"; import type { dvFrontmatterCache } from "../interfaces"; import type BCPlugin from "../main"; import { strToRegex } from "../Utils/generalUtils"; @@ -35,6 +35,7 @@ export function addRegexNotesToGraph( const targets = []; frontms.forEach((page) => { + if (page[BC_IGNORE]) return; const basename = getDVBasename(page.file); if (basename !== regexNoteBasename && regex.test(basename)) targets.push(basename); diff --git a/src/AlternativeHierarchies/TagNotes.ts b/src/AlternativeHierarchies/TagNotes.ts index b42c087d..f58066e5 100644 --- a/src/AlternativeHierarchies/TagNotes.ts +++ b/src/AlternativeHierarchies/TagNotes.ts @@ -2,6 +2,7 @@ import type { MultiGraph } from "graphology"; import { info } from "loglevel"; import type { App, TFile } from "obsidian"; import { + BC_IGNORE, BC_TAG_NOTE, BC_TAG_NOTE_EXACT, BC_TAG_NOTE_FIELD, @@ -58,7 +59,7 @@ export function addTagNotesToGraph( const targets = frontms .map((ff) => ff.file) - .filter((file) => file.path !== tagNoteFile.path && hasThisTag(file)) + .filter((file) => file.path !== tagNoteFile.path && hasThisTag(file) && !file[BC_IGNORE]) .map(getDVBasename); info({ targets }); diff --git a/src/constants.ts b/src/constants.ts index 1cb08a10..fb6d4bbe 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -139,13 +139,13 @@ export const [ BC_I_REFLEXIVE, BC_I_PARENT, ] = [ - "BC-Aunt", - "BC-Cousin", - "BC-Sibling-1", - "BC-Sibling-2", - "BC-Reflexive", - "BC-Parent", -]; + "BC-Aunt", + "BC-Cousin", + "BC-Sibling-1", + "BC-Sibling-2", + "BC-Reflexive", + "BC-Parent", + ]; export const [ BC_FOLDER_NOTE, @@ -160,26 +160,28 @@ export const [ BC_REGEX_NOTE_FIELD, BC_DV_NOTE, BC_DV_NOTE_FIELD, + BC_IGNORE, BC_IGNORE_DENDRON, BC_HIDE_TRAIL, BC_ORDER, ] = [ - "BC-folder-note", - "BC-folder-note-subfolders", - "BC-folder-note-recursive", - "BC-tag-note", - "BC-tag-note-field", - "BC-tag-note-exact", - "BC-link-note", - "BC-traverse-note", - "BC-regex-note", - "BC-regex-note-field", - "BC-dataview-note", - "BC-dataview-note-field", - "BC-ignore-dendron", - "BC-hide-trail", - "BC-order", -]; + "BC-folder-note", + "BC-folder-note-subfolders", + "BC-folder-note-recursive", + "BC-tag-note", + "BC-tag-note-field", + "BC-tag-note-exact", + "BC-link-note", + "BC-traverse-note", + "BC-regex-note", + "BC-regex-note-field", + "BC-dataview-note", + "BC-dataview-note-field", + "BC-ignore", + "BC-ignore-dendron", + "BC-hide-trail", + "BC-order", + ]; export const BC_FIELDS_INFO = [ {