vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

Watch is not effectively utilizing glob patterns #3821

Closed jinguoguang closed 1 week ago

jinguoguang commented 3 weeks ago

Describe the bug

interface Post{
  title: string
  date: Date
  cover: string | undefined
  description: string | undefined
  tags: string[] | undefined
  categorie: string | undefined
  url:string
  author: string | undefined
}

declare const data: Post[]
export { data }
export default createContentLoader(['**/*.md','!**/index.md','!nav.md','!archives.md','!posts.md'], {
  includeSrc: false, 
  render: false,
  excerpt: false,
  transform(raw): Post[] {
  console.log("row",raw);
    return raw
      .map(({url, frontmatter }) => ({
        title: frontmatter.title,
        cover:frontmatter.cover,
        description:frontmatter.description,
        tags:frontmatter.tags,
        categorie:frontmatter.categorie,
        date: frontmatter.date,
        url: url,
        author: frontmatter.author
      }))
  }
})

In the above code, I utilize createContentLoader to retrieve information from all *.md files; however, I do not require data from index.md or nav.md files located in any directory. I have employed glob patterns for this purpose, but they seem not to be taking effect. How should I address this issue?

Reproduction

docs | ---index.md | ---foo.md | --- vue | --- index.md | --- foo2.md

Expected behavior

docs | ---foo.md | --- vue | --- foo2.md

System Info

vitepress-version: 1.0.2

Additional context

No response

Validations