Skip to content

Commit

Permalink
fix(List/Matrix View): 🐛 Display alt link names for implied siblings,…
Browse files Browse the repository at this point in the history
… too
  • Loading branch information
SkepticMystic committed Sep 10, 2021
1 parent 5dfb169 commit 075d8a0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
18 changes: 17 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26484,14 +26484,30 @@ class MatrixView extends obsidian.ItemView {
}
// Create the implied sibling SquareProps
impliedSiblings.forEach((impliedSibling) => {
const altFieldsQ = !!settings.altLinkFields.length;
let alt = null;
if (altFieldsQ) {
const toFile = this.app.metadataCache.getFirstLinkpathDest(impliedSibling, currFile.path);
if (toFile) {
const metadata = this.app.metadataCache.getFileCache(toFile);
settings.altLinkFields.forEach(altLinkField => {
var _a;
const altLink = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.frontmatter) === null || _a === void 0 ? void 0 : _a[altLinkField];
if (altLink) {
alt = altLink;
return;
}
});
}
}
iSameArr.push({
to: impliedSibling,
cls: "internal-link breadcrumbs-link breadcrumbs-implied" +
(this.unresolvedQ(impliedSibling, currFile.path)
? " is-unresolved"
: ""),
// TODO get alt for implied siblings
alt: null
alt
});
});
});
Expand Down
15 changes: 14 additions & 1 deletion src/MatrixView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,19 @@ export default class MatrixView extends ItemView {
}
// Create the implied sibling SquareProps
impliedSiblings.forEach((impliedSibling) => {
const altFieldsQ = !!settings.altLinkFields.length
let alt = null;
if (altFieldsQ) {
const toFile = this.app.metadataCache.getFirstLinkpathDest(impliedSibling, currFile.path)
if (toFile) {
const metadata = this.app.metadataCache.getFileCache(toFile)
settings.altLinkFields.forEach(altLinkField => {
const altLink = metadata?.frontmatter?.[altLinkField]
if (altLink) { alt = altLink; return }
})
}
}

iSameArr.push({
to: impliedSibling,
cls:
Expand All @@ -350,7 +363,7 @@ export default class MatrixView extends ItemView {
? " is-unresolved"
: ""),
// TODO get alt for implied siblings
alt: null
alt
});
});
});
Expand Down

0 comments on commit 075d8a0

Please sign in to comment.