Skip to content

Commit

Permalink
feat(DendronNote): ✨ Add BC-ignore-dendron: true to not treat a den…
Browse files Browse the repository at this point in the history
…dron note as such (Fix #277)
  • Loading branch information
SkepticMystic committed Jan 15, 2022
1 parent 7dede34 commit f75653d
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions src/AlternativeHierarchies/DendronNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,32 @@ export function addDendronNotesToGraph(
for (const frontm of frontms) {
// Doesn't currently work yet
if (frontm[BC_IGNORE_DENDRON]) continue;
const { file } = frontm;
const basename = getDVBasename(file);

const basename = getDVBasename(frontm.file);

const splits = basename.split(dendronNoteDelimiter);
if (splits.length < 2) continue;

// Probably inefficient to reverse then unreverse it. I can probably just use slice(-i)
const reversed = splits.reverse();
reversed.forEach((split, i) => {
const currSlice = reversed.slice(i).reverse().join(dendronNoteDelimiter);
const nextSlice = reversed
.slice(i + 1)
.reverse()
.join(dendronNoteDelimiter);
if (!nextSlice) return;

const sourceOrder = getSourceOrder(frontm);
const targetOrder = getTargetOrder(frontms, nextSlice);

populateMain(
settings,
mainG,
currSlice,
dendronNoteField,
nextSlice,
sourceOrder,
targetOrder,
true
);
});
if (splits.length <= 1) continue;

const nextSlice = splits.slice(0, -1).join(dendronNoteDelimiter);
if (!nextSlice) continue;
const nextSliceFile = frontms.find(
(fm) => getDVBasename(fm.file) === nextSlice
);

if (!nextSliceFile || nextSliceFile[BC_IGNORE_DENDRON]) continue;

const sourceOrder = getSourceOrder(frontm);
const targetOrder = getTargetOrder(frontms, nextSlice);

populateMain(
settings,
mainG,
basename,
dendronNoteField,
nextSlice,
sourceOrder,
targetOrder,
true
);
}
}

0 comments on commit f75653d

Please sign in to comment.