iles: `useDocuments` paths are incorrectly resolved in Windows

Description 📖

<script setup lang="ts">
const posts = useDocuments("~/posts")
</script>

<template>
  <a v-for="post of posts" :key="post.href" :href="post.href">
    {{ post.title }}
   <component :is="post" excerpt />
  </a>
</template>

Similar code appears differently in different components (specifically, Header.vue and List.vue). Header.vue is fine, while List.vue has a problem, the prompt tells me that HelloWorld.md cannot be found, the file actually exists and according to the error it links to an incorrect directory(C:\src\posts\HelloWorld.md).

Possible useful information: I am using Windows 11 and pnpm

Reproduction 🐞

Please provide a link to a repo that can reproduce the problem you ran into.

https://github.com/kecrily/iles-bug-reproduction

Dependencies Info

Run npx iles info and pnpm list (or npm list) and provide the output:

iles v0.7.21 vite v2.7.10

devDependencies:
iles 0.7.21
typescript 4.5.4
vite 2.7.10
vue-tsc 0.29.8

Logs 📜

If not providing a reproduction:

Output

Run DEBUG=iles:* npm run dev or DEBUG=iles:* npm run build and provide the output:


Screenshots 📷

Provide console or browser screenshots of the problem.

image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (18 by maintainers)

Most upvoted comments

Fixed in @islands/pages 0.7.8.

Thanks again @kecrily for providing detailed error information! Try running pnpm upgrade, and it should bump the versions automatically.

The logs returned by this command are still the same, but the logs that are needed after visiting the page appear. I think the original command worked too, I just didn’t visit the page

Details
iles:pages:gen routes: [
  iles:pages:gen   {
  iles:pages:gen     name: 'index',
  iles:pages:gen     path: '/',
  iles:pages:gen     frontmatter: { layout: undefined, meta: [Object], route: {} },
  iles:pages:gen     componentFilename: 'C:/Users/kecrily/Desktop/dev/iles-bug-reproduction/src/pages/index.mdx'
  iles:pages:gen   },
  iles:pages:gen   {
  iles:pages:gen     name: 'about',
  iles:pages:gen     path: '/about',
  iles:pages:gen     frontmatter: { layout: undefined, meta: [Object], route: {}, title: 'About' },
  iles:pages:gen     componentFilename: 'C:/Users/kecrily/Desktop/dev/iles-bug-reproduction/src/pages/about.md'       
  iles:pages:gen   },
  iles:pages:gen   {
  iles:pages:gen     path: '/:zzz(.*)*',
  iles:pages:gen     name: 'NotFoundInDev',
  iles:pages:gen     componentFilename: '@islands/components/NotFound'
  iles:pages:gen   }
  iles:pages:gen ] +0ms
8:57:01 [vite] ENOENT: no such file or directory, stat 'C:\src\posts\HelloWorld.md'
  iles:documents ~/posts {
  iles:documents   path: 'src/posts',
  iles:documents   pattern: 'src/posts/**/*.{md,mdx}',
  iles:documents   files: [ 'src/posts/HelloWorld.md' ]
  iles:documents } +0ms
8:57:02 [vite] ENOENT: no such file or directory, stat 'C:\src\posts\HelloWorld.md' (x2)
  iles:documents ~/posts {
  iles:documents   path: 'src/posts',
  iles:documents   pattern: 'src/posts/**/*.{md,mdx}',
  iles:documents   files: [ 'src/posts/HelloWorld.md' ]
  iles:documents } +662ms

Adding resolve(root, file) here might do the trick.

Already using pathe in all internal packages.