Closed
Description
Describe the bug
After upgrading to version 2.0.0-alpha7, pages in createContentLoader is rendered asynchronously, the docs seem to be wrong.
Reproduction
To minimize disruption, I pasted the example codes to my project, and the issue is still existing.
import { createContentLoader } from 'vitepress'
export default createContentLoader('posts/*.md', {
includeSrc: true, // include raw markdown source?
render: true, // include rendered full page HTML?
excerpt: true, // include excerpt?
transform(rawData) {
// map, sort, or filter the raw data as you wish.
// the final result is what will be shipped to the client.
return rawData.sort((a, b) => {
return +new Date(b.frontmatter.date) - +new Date(a.frontmatter.date)
}).map((page) => {
page.src // raw markdown source
page.html // rendered full page HTML
page.excerpt // rendered excerpt HTML (content above first `---`)
return {/* ... */}
})
}
})
<script setup>
import { data as posts } from './posts.data.js'
</script>
<body>
<h1>All Blog Posts</h1>
<ul>
<li v-for="post of posts">
<a :href="post.url">{{ post.frontmatter.title }}</a>
<span>by {{ post.frontmatter.author }}</span>
</li>
</ul>
<body>
Expected behavior
The post list should not be empty.
System Info
System:
OS: Windows 11 10.0.26100
CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-13700K
Memory: 4.18 GB / 11.98 GB
Binaries:
Node: 22.17.0 - C:\Program Files\nodejs\node.EXE
npm: 11.4.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Chromium (129.0.2792.65)
npmPackages:
vitepress: ^2.0.0-alpha.7 => 2.0.0-alpha.7
Additional context
I have checked following steps:
- Codes I copied are not modified except path.
- The paths are correct.
- The file list is not empty.
If you can not reproduct the issue, I can provide my project.
Validations
- Check if you're on the latest VitePress version.
- Follow our Code of Conduct
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
No labels