Skip to content

Commit 74d9ba2

Browse files
authored
fix(build): createContentLoader generates invalid url when srcDir is set (#2578)
BREAKING CHANGE: `createContentLoader` will now resolve globs relative to `srcDir` instead of `root`
1 parent fb048a6 commit 74d9ba2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/guide/data-loading.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ import { createContentLoader } from 'vitepress'
9191
export default createContentLoader('posts/*.md', /* options */)
9292
```
9393

94-
The helper takes a glob pattern relative to [project root](./routing#project-root), and returns a `{ watch, load }` data loader object that can be used as the default export in a data loader file. It also implements caching based on file modified timestamps to improve dev performance.
94+
The helper takes a glob pattern relative to the [source directory](./routing#source-directory), and returns a `{ watch, load }` data loader object that can be used as the default export in a data loader file. It also implements caching based on file modified timestamps to improve dev performance.
9595

9696
Note the loader only works with Markdown files - matched non-Markdown files will be skipped.
9797

src/node/contentLoader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function createContentLoader<T = ContentData[]>(
115115
})
116116
const url =
117117
'/' +
118-
normalizePath(path.relative(config.root, file)).replace(
118+
normalizePath(path.relative(config.srcDir, file)).replace(
119119
/\.md$/,
120120
config.cleanUrls ? '' : '.html'
121121
)

0 commit comments

Comments
 (0)