From 6d7422f8fa321c641b1d5be3fa0c382400a2b78f Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Thu, 25 Sep 2025 15:18:18 +0530 Subject: [PATCH] fix: respect markdown.cache = false on build too --- src/node/markdownToVue.ts | 35 +++++++++-------------------------- src/node/plugin.ts | 1 - 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/node/markdownToVue.ts b/src/node/markdownToVue.ts index 87ecc985..2a6c5b01 100644 --- a/src/node/markdownToVue.ts +++ b/src/node/markdownToVue.ts @@ -83,7 +83,6 @@ function getResolutionCache(siteConfig: SiteConfig) { export async function createMarkdownToVueRenderFn( srcDir: string, options: MarkdownOptions = {}, - isBuild = false, base = '/', includeLastUpdatedData = false, cleanUrls = false, @@ -115,7 +114,7 @@ export async function createMarkdownToVueRenderFn( const relativePath = slash(path.relative(srcDir, file)) const cacheKey = JSON.stringify({ src, ts, relativePath }) - if (isBuild || options.cache !== false) { + if (options.cache !== false) { const cached = cache.get(cacheKey) if (cached) { debug(`[cache hit] ${relativePath}`) @@ -177,15 +176,9 @@ export async function createMarkdownToVueRenderFn( } return siteConfig.ignoreDeadLinks.some((ignore) => { - if (typeof ignore === 'string') { - return url === ignore - } - if (ignore instanceof RegExp) { - return ignore.test(url) - } - if (typeof ignore === 'function') { - return ignore(url, fileOrig) - } + if (typeof ignore === 'string') return url === ignore + if (ignore instanceof RegExp) return ignore.test(url) + if (typeof ignore === 'function') return ignore(url, fileOrig) return false }) } @@ -198,6 +191,7 @@ export async function createMarkdownToVueRenderFn( url = url.replace(/[?#].*$/, '').replace(/\.(html|md)$/, '') if (url.endsWith('/')) url += `index` + let resolved = decodeURIComponent( slash( url.startsWith('/') @@ -207,6 +201,7 @@ export async function createMarkdownToVueRenderFn( ) resolved = siteConfig?.rewrites.inv[resolved + '.md']?.slice(0, -3) || resolved + if ( !pages.includes(resolved) && !fs.existsSync(path.resolve(dir, publicDir, `${resolved}.html`)) && @@ -239,12 +234,7 @@ export async function createMarkdownToVueRenderFn( for (const fn of transformPageData) { if (fn) { const dataToMerge = await fn(pageData, { siteConfig }) - if (dataToMerge) { - pageData = { - ...pageData, - ...dataToMerge - } - } + if (dataToMerge) pageData = { ...pageData, ...dataToMerge } } } @@ -260,15 +250,8 @@ export async function createMarkdownToVueRenderFn( debug(`[render] ${file} in ${Date.now() - start}ms.`) - const result = { - vueSrc, - pageData, - deadLinks, - includes - } - if (isBuild || options.cache !== false) { - cache.set(cacheKey, result) - } + const result = { vueSrc, pageData, deadLinks, includes } + if (options.cache !== false) cache.set(cacheKey, result) return result } } diff --git a/src/node/plugin.ts b/src/node/plugin.ts index 18eebcac..26d32fb6 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -116,7 +116,6 @@ export async function createVitePressPlugin( markdownToVue = await createMarkdownToVueRenderFn( srcDir, markdown, - config.command === 'build', config.base, lastUpdated, cleanUrls,