Skip to content

Commit

Permalink
fix(DownView): 🐛 Don't depend on Create Index > make wikilinks setting
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 30, 2021
1 parent 6e1147f commit 61c9770
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
13 changes: 7 additions & 6 deletions src/Components/Down.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { info } from "loglevel";
import {
hoverPreview,
isInVault,
Expand Down Expand Up @@ -36,13 +37,13 @@
const down = getSubInDirs(closed, "down");
const allPaths = dfsAllPaths(down, basename);
const index = plugin.createIndex(allPaths);
console.log({ allPaths, index, down: down.inspect() });
const index = plugin.createIndex(allPaths, false);
info({ allPaths, index });
lines = index.split("\n").map((line) => line.split("- ")) as [
string,
string
][];
lines = index
.split("\n")
.map((line) => line.split("- "))
.filter((pair) => pair.length > 1) as [string, string][];
}
</script>

Expand Down
7 changes: 4 additions & 3 deletions src/Components/Stats.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@
nodesToo = true
) {
const gInfo = hierData[dir][gType];
const { wikilinkIndex } = settings;
if (nodesToo) {
gInfo.nodes = gInfo.graph.nodes();
gInfo.nodesStr = gInfo.nodes
.map((n) => makeWiki(settings.wikilinkIndex, n))
.map((n) => makeWiki(n, wikilinkIndex))
.join("\n");
}
gInfo.edges = gInfo.graph.edges();
const edgeStrArr = gInfo.graph.mapEdges(
(k, a, s, t) =>
`${makeWiki(settings.wikilinkIndex, nodesToo ? s : t)} ${
`${makeWiki(nodesToo ? s : t, wikilinkIndex)} ${
ARROW_DIRECTIONS[dir]
} ${makeWiki(settings.wikilinkIndex, nodesToo ? t : s)}`
} ${makeWiki(nodesToo ? t : s, wikilinkIndex)}`
);
gInfo.edgesStr = edgeStrArr.join("\n");
}
Expand Down
13 changes: 7 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1147,9 +1147,11 @@ export default class BCPlugin extends Plugin {

// !SECTION OneSource

createIndex(allPaths: string[][]): string {
createIndex(
allPaths: string[][],
asWikilinks: boolean = this.settings.wikilinkIndex
): string {
let index = "";
const { wikilinkIndex, aliasesInIndex } = this.settings;
const copy = cloneDeep(allPaths);
const reversed = copy.map((path) => path.reverse());
reversed.forEach((path) => path.shift());
Expand All @@ -1171,10 +1173,9 @@ export default class BCPlugin extends Plugin {
) {
continue;
} else {
index += `${indent.repeat(depth)}- ${makeWiki(
wikilinkIndex,
currNode
)}`;
index += `${indent.repeat(depth)}- ${
asWikilinks ? makeWiki(currNode) : currNode
}`;

index += "\n";

Expand Down
2 changes: 1 addition & 1 deletion src/sharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function complement<T>(A: T[], B: T[]) {
return A.filter((a) => !B.includes(a));
}

export function makeWiki(wikiQ: boolean, str: string) {
export function makeWiki(str: string, wikiQ = true) {
let copy = str.slice();
if (wikiQ) {
copy = "[[" + copy;
Expand Down

0 comments on commit 61c9770

Please sign in to comment.