From 09d8d98f93ee9e36ac1f8a01f3d2126f0cffe80a Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Sat, 14 Aug 2021 10:49:33 +0200 Subject: [PATCH] feat(Juggl): :sparkles: Use only Juggl links --- src/BreadcrumbsSettingTab.ts | 17 ++++++++++++++++- src/interfaces.ts | 1 + src/main.ts | 4 ++-- src/sharedFunctions.ts | 6 +++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/BreadcrumbsSettingTab.ts b/src/BreadcrumbsSettingTab.ts index e2f1adf3..ebb480d9 100644 --- a/src/BreadcrumbsSettingTab.ts +++ b/src/BreadcrumbsSettingTab.ts @@ -228,7 +228,22 @@ export class BreadcrumbsSettingTab extends PluginSettingTab { ); new Setting(generalDetails) - .setName("Use Juggl link syntax without having Juggl installed") + .setName("Use yaml or inline fields for hierarchy data") + .setDesc( + "If enabled, Breadcrumbs will make it's hierarchy using yaml fields, and inline fields (if you have Dataview enabled). If this is disabled, it will only use Juggl links for it's metadata (See below)." + ) + .addToggle((toggle) => + toggle + .setValue(plugin.settings.useAllMetadata) + .onChange(async (value) => { + plugin.settings.useAllMetadata = value; + await plugin.saveSettings(); + await plugin.refreshIndex(); + }) + ); + + new Setting(generalDetails) + .setName("Use Juggl link syntax without having Juggl installed.") .setDesc( "Should Breadcrumbs look for [Juggl links](https://juggl.io/Link+Types) even if you don't have Juggl installed? If you do have Juggl installed, it will always look for Juggl links." ) diff --git a/src/interfaces.ts b/src/interfaces.ts index 52c9654e..5fbb6080 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -5,6 +5,7 @@ export interface BreadcrumbsSettings { userHierarchies: userHierarchy[]; indexNote: string[]; refreshIndexOnActiveLeafChange: boolean; + useAllMetadata: boolean; parseJugglLinksWithoutJuggl: boolean; dvWaitTime: number; refreshIntervalTime: number; diff --git a/src/main.ts b/src/main.ts index c52d25b4..a8f2b689 100644 --- a/src/main.ts +++ b/src/main.ts @@ -42,6 +42,7 @@ const DEFAULT_SETTINGS: BreadcrumbsSettings = { userHierarchies: [], indexNote: [""], refreshIndexOnActiveLeafChange: false, + useAllMetadata: true, parseJugglLinksWithoutJuggl: false, dvWaitTime: 5000, refreshIntervalTime: 0, @@ -393,9 +394,8 @@ export default class BreadcrumbsPlugin extends Plugin { } }); - console.log({ graphs }); - debug(this.settings, "graphs inited"); + debug(this.settings, { graphs }); return graphs; } diff --git a/src/sharedFunctions.ts b/src/sharedFunctions.ts index ae4a09cb..79da228e 100644 --- a/src/sharedFunctions.ts +++ b/src/sharedFunctions.ts @@ -267,6 +267,8 @@ export async function getNeighbourObjArr( const fieldsArr = Object.values(hier) as [string[], string[], string[]]; const newHier: HierarchyFields = { up: {}, same: {}, down: {} }; + // Add regular metadata links + if (plugin.settings.useAllMetadata) { DIRECTIONS.forEach((dir, i) => { fieldsArr[i].forEach((field) => { newHier[dir][field] = getFieldValues( @@ -276,7 +278,9 @@ export async function getNeighbourObjArr( ); }); }); + } + // Add Juggl Links if (jugglLinks.length) { const jugglLinksInFile = jugglLinks.filter((jugglLink) => { return jugglLink.note === currFileName; @@ -287,7 +291,7 @@ export async function getNeighbourObjArr( if ((hier[line.dir] as string[]).includes(line.type)) { newHier[line.dir][line.type] = [ ...new Set([ - ...(newHier[line.dir][line.type] as string[]), + ...(newHier[line.dir][line.type] ?? []), ...line.linksInLine, ]), ];