From 0d839ac2b5e37af119b098c1738f44082837817b Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Sun, 9 Jan 2022 20:48:14 +0200 Subject: [PATCH] feat(FolderNote): :sparkles: `BC-folder-note-subfolders: true` takes notes in subfolders of the folderNote and adds those notes, too (#218) --- main.js | 14 ++++++++++++-- src/constants.ts | 8 ++++++++ src/main.ts | 7 ++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 4cd893b7..3276343e 100644 --- a/main.js +++ b/main.js @@ -21029,8 +21029,9 @@ const blankRealNImplied = () => { prev: { reals: [], implieds: [] }, }; }; -const [BC_FOLDER_NOTE, 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_HIDE_TRAIL, BC_ORDER,] = [ +const [BC_FOLDER_NOTE, BC_FOLDER_NOTE_SUBFOLDER, 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_HIDE_TRAIL, BC_ORDER,] = [ "BC-folder-note", + "BC-folder-note-subfolder", "BC-tag-note", "BC-tag-note-field", "BC-tag-note-exact", @@ -21048,6 +21049,12 @@ const BC_FIELDS_INFO = [ after: ": ", alt: true, }, + { + field: BC_FOLDER_NOTE_SUBFOLDER, + desc: "This folder note should take notes in the same folder as it, _and_ notes in subfolders of it.", + after: ": true", + alt: false, + }, { field: BC_TAG_NOTE, desc: "Set this note as a Breadcrumbs tag-note. All other notes with this tag will be added to the graph using the default fieldName specified in `Settings > Alternative Hierarchies > Tag Notes > Default Field`, or using the fieldName you specify with `BC-tag-note-field: fieldName`", @@ -53442,9 +53449,12 @@ class BCPlugin extends require$$0.Plugin { const { file } = altFile; const basename = getDVBasename(file); const folder = getFolder(file); + const subfolders = altFile[BC_FOLDER_NOTE_SUBFOLDER]; const targets = frontms .map((ff) => ff.file) - .filter((other) => getFolder(other) === folder && other.path !== file.path) + .filter((other) => (subfolders + ? getFolder(other).includes(folder) + : getFolder(other) === folder) && other.path !== file.path) .map(getDVBasename); const field = altFile[BC_FOLDER_NOTE]; if (typeof field !== "string" || !fields.includes(field)) diff --git a/src/constants.ts b/src/constants.ts index 9835ebd5..721d56cb 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -84,6 +84,7 @@ export const blankRealNImplied = () => { export const [ BC_FOLDER_NOTE, + BC_FOLDER_NOTE_SUBFOLDER, BC_TAG_NOTE, BC_TAG_NOTE_FIELD, BC_TAG_NOTE_EXACT, @@ -95,6 +96,7 @@ export const [ BC_ORDER, ] = [ "BC-folder-note", + "BC-folder-note-subfolder", "BC-tag-note", "BC-tag-note-field", "BC-tag-note-exact", @@ -113,6 +115,12 @@ export const BC_FIELDS_INFO = [ after: ": ", alt: true, }, + { + field: BC_FOLDER_NOTE_SUBFOLDER, + desc: "This folder note should take notes in the same folder as it, _and_ notes in subfolders of it.", + after: ": true", + alt: false, + }, { field: BC_TAG_NOTE, desc: "Set this note as a Breadcrumbs tag-note. All other notes with this tag will be added to the graph using the default fieldName specified in `Settings > Alternative Hierarchies > Tag Notes > Default Field`, or using the fieldName you specify with `BC-tag-note-field: fieldName`", diff --git a/src/main.ts b/src/main.ts index ecf6e86b..bcb97f37 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,6 +31,7 @@ import TrailPath from "./Components/TrailPath.svelte"; import { BC_ALTS, BC_FOLDER_NOTE, + BC_FOLDER_NOTE_SUBFOLDER, BC_HIDE_TRAIL, BC_LINK_NOTE, BC_ORDER, @@ -1159,11 +1160,15 @@ export default class BCPlugin extends Plugin { const { file } = altFile; const basename = getDVBasename(file); const folder = getFolder(file); + const subfolders = altFile[BC_FOLDER_NOTE_SUBFOLDER]; const targets = frontms .map((ff) => ff.file) .filter( - (other) => getFolder(other) === folder && other.path !== file.path + (other) => + (subfolders + ? getFolder(other).includes(folder) + : getFolder(other) === folder) && other.path !== file.path ) .map(getDVBasename);