diff --git a/index.d.ts b/index.d.ts index 46281d3..9baa6a0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -45,6 +45,7 @@ type WikilinkMeta = { link: string slug: string isEmbed: boolean + exists: boolean // href and path are loaded from the linked page href?: string diff --git a/src/interlinker.js b/src/interlinker.js index c2a44b2..0111e2e 100644 --- a/src/interlinker.js +++ b/src/interlinker.js @@ -150,7 +150,7 @@ module.exports = class Interlinker { // If this is an embed and the embed template hasn't been compiled, add this to the queue // @TODO compiledEmbeds should be keyed by the wikilink text as i'll be allowing setting embed values via namespace, or other method e.g ![[ident||template]] - if (link.isEmbed && this.compiledEmbeds.has(link.slug) === false) { + if (link.isEmbed && link.exists && this.compiledEmbeds.has(link.slug) === false) { compilePromises.push(this.compileTemplate(page)); } diff --git a/src/wikilink-parser.js b/src/wikilink-parser.js index 3ceed47..af27b07 100644 --- a/src/wikilink-parser.js +++ b/src/wikilink-parser.js @@ -74,7 +74,8 @@ module.exports = class WikilinkParser { anchor, link, slug, - isEmbed + isEmbed, + exists: false, } // Lookup page data from 11ty's collection to obtain url and title if currently null @@ -83,6 +84,7 @@ module.exports = class WikilinkParser { if (meta.title === null && page.data.title) meta.title = page.data.title; meta.href = page.url; meta.path = page.inputPath; + meta.exists = true; } else { // If this wikilink goes to a page that doesn't exist, add to deadLinks list and // update href for stub post. diff --git a/tests/eleventy.test.js b/tests/eleventy.test.js index 699c728..7210722 100644 --- a/tests/eleventy.test.js +++ b/tests/eleventy.test.js @@ -123,3 +123,17 @@ test("Sample page (files with hash in title)", async t => { `
This link should be to a fragment identifier.
Hello world.
[UNABLE TO LOCATE EMBED]