Skip to content

Commit

Permalink
fix(aliases): simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyurec committed Oct 2, 2022
1 parent 62ba786 commit 2c2394d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ From Logseq store - `Plugins -> Marketplace`.
### ✨ Page icons

Enable feature to show Logseq page (or aliased page) icon for internal links in content.
In addition you can config icon inheriting from related page (or its alias) proprty, to avoid manual setting `icon::` for common pages.
In addition you can config icon inheriting from related page proprty, to avoid manual setting `icon::` for common pages.
For ex.:
* create "Projects" page, set `icon::` for it
* create "Some project" page, set `page-type:: [[Projects]]`
Expand Down
28 changes: 14 additions & 14 deletions src/js/awesomeLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ const setPageIcons = async (linkList: NodeListOf<HTMLAnchorElement>) => {
}

if (!pageIcon && pluginConfig.featureInheritPageIcons) {
if (!pageIcon) {
// inherited from page props, when props linked to page
const inheritedPropsTitle = await getInheritedPropsTitle(pageTitle, pluginConfig.featureInheritPageIcons);
if (inheritedPropsTitle) {
pageIcon = await getPageIcon(inheritedPropsTitle);
// if (!pageIcon) {
// // inherited from page props, when props linked to aliased
// const aliasedPageTitle = await getAliasedPageTitle(inheritedPropsTitle);
// if (aliasedPageTitle) {
// pageIcon = await getPageIcon(aliasedPageTitle);
// }
// }
}
}
if (!pageIcon) {
// inherited from aliased page props, when props linked to page
const aliasedPageTitle = await getAliasedPageTitle(pageTitle);
Expand All @@ -206,20 +220,6 @@ const setPageIcons = async (linkList: NodeListOf<HTMLAnchorElement>) => {
}
}
}
if (!pageIcon) {
// inherited from page props, when props linked to page
const inheritedPropsTitle = await getInheritedPropsTitle(pageTitle, pluginConfig.featureInheritPageIcons);
if (inheritedPropsTitle) {
pageIcon = await getPageIcon(inheritedPropsTitle);
if (!pageIcon) {
// inherited from page props, when props linked to aliased
const aliasedPageTitle = await getAliasedPageTitle(inheritedPropsTitle);
if (aliasedPageTitle) {
pageIcon = await getPageIcon(aliasedPageTitle);
}
}
}
}
}
if (pageIcon) {
linkItem.insertAdjacentHTML('afterbegin', `<span class="link-icon">${pageIcon}</span>`);
Expand Down

0 comments on commit 2c2394d

Please sign in to comment.