Skip to content

Commit

Permalink
feat: ✨ BC-ignore: true to ignore a note from BC entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Apr 17, 2022
1 parent 042dd33 commit 9e719a7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 29 deletions.
3 changes: 2 additions & 1 deletion src/AlternativeHierarchies/DataviewNotes.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/AlternativeHierarchies/DendronNotes.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/AlternativeHierarchies/FolderNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/AlternativeHierarchies/RegexNotes.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/AlternativeHierarchies/TagNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 });

Expand Down
48 changes: 25 additions & 23 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = [
{
Expand Down

0 comments on commit 9e719a7

Please sign in to comment.