From 1a8088cae284b5ab10a6a0d7ca9e7577050372b7 Mon Sep 17 00:00:00 2001 From: Brad Veryard Date: Mon, 14 Oct 2024 22:09:10 +0800 Subject: [PATCH] fix(deadlinks): Check if public file exists --- src/node/markdownToVue.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/node/markdownToVue.ts b/src/node/markdownToVue.ts index 21ea491b..6cdf6d5a 100644 --- a/src/node/markdownToVue.ts +++ b/src/node/markdownToVue.ts @@ -176,9 +176,15 @@ export async function createMarkdownToVueRenderFn( ) resolved = siteConfig?.rewrites.inv[resolved + '.md']?.slice(0, -3) || resolved + + const htmlFileExists = fs.existsSync(path.resolve(dir, publicDir, `${resolved}.html`)) + const checkIfPublicFileExists = fs.existsSync(path.resolve(dir, publicDir, resolved)) + if ( !pages.includes(resolved) && - !fs.existsSync(path.resolve(dir, publicDir, `${resolved}.html`)) && + ( + !htmlFileExists && !checkIfPublicFileExists + ) && !shouldIgnoreDeadLink(url) ) { recordDeadLink(url) @@ -273,15 +279,14 @@ function injectPageDataCode(tags: string[], data: PageData) { tags[existingScriptIndex] = tagSrc.replace( scriptRE, code + - (hasDefaultExport - ? `` - : `\nexport default {name:${JSON.stringify(data.relativePath)}}`) + - `` + (hasDefaultExport + ? `` + : `\nexport default {name:${JSON.stringify(data.relativePath)}}`) + + `` ) } else { tags.unshift( - ``