diff --git a/main.js b/main.js index 3db55b63..6c8d2b26 100644 --- a/main.js +++ b/main.js @@ -21145,6 +21145,7 @@ const DEFAULT_SETTINGS = { regexNoteField: "", rlLeaf: true, showAllPathsIfNoneToIndexNote: false, + showAllAliases: true, showBCs: true, showBCsInEditLPMode: false, showRefreshNotice: true, @@ -24893,15 +24894,16 @@ class MatrixView extends require$$0.ItemView { } getAlt(node) { var _a; - const { altLinkFields } = this.plugin.settings; + const { altLinkFields, showAllAliases } = this.plugin.settings; if (altLinkFields.length) { const file = this.app.metadataCache.getFirstLinkpathDest(node, ""); if (file) { const metadata = this.app.metadataCache.getFileCache(file); for (const altField of altLinkFields) { const value = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.frontmatter) === null || _a === void 0 ? void 0 : _a[altField]; + const arr = typeof value === "string" ? splitAndTrim(value) : value; if (value) - return value; + return showAllAliases ? arr.join(", ") : arr[0]; } } } @@ -25183,6 +25185,14 @@ class BCSettingTab extends require$$0.PluginSettingTab { await plugin.saveSettings(); }; }); + new require$$0.Setting(generalDetails) + .setName("Only show first alias") + .setDesc("If a note has an alias (using the fields in the setting above), should only the first one be shown?") + .addToggle((toggle) => toggle.setValue(!settings.showAllAliases).onChange(async (value) => { + settings.showAllAliases = !value; + await plugin.saveSettings(); + await plugin.refreshIndex(); + })); new require$$0.Setting(generalDetails) .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).\nIf this is disabled, it will only use Juggl links for it's metadata (See below).") diff --git a/src/BreadcrumbsSettingTab.ts b/src/BreadcrumbsSettingTab.ts index a00f3eb6..57425008 100644 --- a/src/BreadcrumbsSettingTab.ts +++ b/src/BreadcrumbsSettingTab.ts @@ -153,6 +153,19 @@ export class BCSettingTab extends PluginSettingTab { }; }); + new Setting(generalDetails) + .setName("Only show first alias") + .setDesc( + "If a note has an alias (using the fields in the setting above), should only the first one be shown?" + ) + .addToggle((toggle) => + toggle.setValue(!settings.showAllAliases).onChange(async (value) => { + settings.showAllAliases = !value; + await plugin.saveSettings(); + await plugin.refreshIndex(); + }) + ); + new Setting(generalDetails) .setName("Use yaml or inline fields for hierarchy data") .setDesc( diff --git a/src/MatrixView.ts b/src/MatrixView.ts index 03338d37..8bdbe505 100644 --- a/src/MatrixView.ts +++ b/src/MatrixView.ts @@ -17,7 +17,7 @@ import type { UserHier, } from "./interfaces"; import type BCPlugin from "./main"; -import { getRealnImplied, linkClass } from "./sharedFunctions"; +import { getRealnImplied, linkClass, splitAndTrim } from "./sharedFunctions"; export default class MatrixView extends ItemView { private plugin: BCPlugin; @@ -64,14 +64,17 @@ export default class MatrixView extends ItemView { } getAlt(node: string): string | null { - const { altLinkFields } = this.plugin.settings; + const { altLinkFields, showAllAliases } = this.plugin.settings; if (altLinkFields.length) { const file = this.app.metadataCache.getFirstLinkpathDest(node, ""); if (file) { const metadata = this.app.metadataCache.getFileCache(file); for (const altField of altLinkFields) { const value = metadata?.frontmatter?.[altField]; - if (value) return value; + + const arr: string[] = + typeof value === "string" ? splitAndTrim(value) : value; + if (value) return showAllAliases ? arr.join(", ") : arr[0]; } } } else return null; diff --git a/src/constants.ts b/src/constants.ts index e8cab8e5..1e82df0f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -214,6 +214,7 @@ export const DEFAULT_SETTINGS: BCSettings = { regexNoteField: "", rlLeaf: true, showAllPathsIfNoneToIndexNote: false, + showAllAliases: true, showBCs: true, showBCsInEditLPMode: false, showRefreshNotice: true, diff --git a/src/interfaces.ts b/src/interfaces.ts index f6fe4357..fd82d40b 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -54,6 +54,7 @@ export interface BCSettings { refreshOnNoteChange: boolean; respectReadableLineLength: boolean; showAllPathsIfNoneToIndexNote: boolean; + showAllAliases: boolean; showNameOrType: boolean; showRelationType: boolean; showWriteAllBCsCmd: boolean;