Skip to content

Commit

Permalink
bugfix(#41): use alias as link text if lookup source
Browse files Browse the repository at this point in the history
  • Loading branch information
carbontwelve committed May 4, 2024
1 parent 3d1d74e commit f46e8d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/html-link-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = class HTMLLinkParser {
isEmbed: false,
};

if (!pageDirectory.findByLink(meta)) {
if (!pageDirectory.findByLink(meta).found) {
this.deadLinks.add(link);
}

Expand Down
4 changes: 2 additions & 2 deletions src/interlinker.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ module.exports = class Interlinker {
...this.HTMLLinkParser.find(pageContent, pageDirectory),
].map((link) => {
// Lookup the page this link, links to and add this page to its backlinks
const page = pageDirectory.findByLink(link);
if (!page) return link;
const {page, found} = pageDirectory.findByLink(link);
if (!found) return link;

if (!page.data.backlinks) {
page.data.backlinks = [];
Expand Down
8 changes: 6 additions & 2 deletions src/wikilink-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ module.exports = class WikilinkParser {
}

// Lookup page data from 11ty's collection to obtain url and title if currently null
const page = pageDirectory.findByLink(meta);
const {page, foundByAlias} = pageDirectory.findByLink(meta);
if (page) {
if (meta.title === null && page.data.title) meta.title = page.data.title;
if (foundByAlias) {
meta.title = meta.name;
} else if (meta.title === null && page.data.title) {
meta.title = page.data.title;
}
meta.href = page.url;
meta.path = page.inputPath;
meta.exists = true;
Expand Down

0 comments on commit f46e8d5

Please sign in to comment.