fix(build): apply rewrites when computing createContentLoader urls

URLs were derived from the source path only, so loader-generated links
pointed at the pre-rewrite location and 404ed for rewritten pages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pull/5014/head
Divyansh Singh 2 months ago
parent 6b64f3561b
commit 9e2148d75e

@ -131,9 +131,10 @@ export function createContentLoader<T = ContentData[]>(
: { excerpt: renderExcerpt as any } // gray-matter types are wrong : { excerpt: renderExcerpt as any } // gray-matter types are wrong
) )
const relFile = normalizePath(path.relative(config.srcDir, file))
const url = const url =
'/' + '/' +
normalizePath(path.relative(config.srcDir, file)) (config.rewrites.map[relFile] || relFile)
.replace(/(^|\/)index\.md$/, '$1') .replace(/(^|\/)index\.md$/, '$1')
.replace(/\.md$/, config.cleanUrls ? '' : '.html') .replace(/\.md$/, config.cleanUrls ? '' : '.html')

Loading…
Cancel
Save