From 4c456035012a87f95316a54c75fcf9645e91c5f5 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Thu, 16 Dec 2021 09:54:36 +0200 Subject: [PATCH] fix(List/Matrix View): :bug: Break when an altField is found --- src/MatrixView.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/MatrixView.ts b/src/MatrixView.ts index d9a49894..b7082ef0 100644 --- a/src/MatrixView.ts +++ b/src/MatrixView.ts @@ -70,17 +70,16 @@ export default class MatrixView extends ItemView { getAlt(node: string): string | null { const { altLinkFields } = this.plugin.settings; - let alt = null; if (altLinkFields.length) { const file = this.app.metadataCache.getFirstLinkpathDest(node, ""); if (file) { const metadata = this.app.metadataCache.getFileCache(file); - altLinkFields.forEach((altLinkField) => { - alt = metadata?.frontmatter?.[altLinkField]; - }); + for (const altField of altLinkFields) { + const value = metadata?.frontmatter?.[altField]; + if (value) return value; + } } - } - return alt; + } else return null; } toInternalLinkObj = (