nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.12k stars 622 forks source link

findSurround() return array is always [null,null] #1547

Closed michaelvcolianna closed 2 years ago

michaelvcolianna commented 2 years ago

Environment

Primary

Nuxi 3.0.0-rc.10                                                                        14:29:14
RootDir: /Users/michaelcolianna/Sites/nuxtkiwis                                         14:29:15
Nuxt project info: (copied to clipboard)                                                14:29:15

------------------------------
- Operating System: `Darwin`
- Node Version:     `v16.16.0`
- Nuxt Version:     `3.0.0-rc.10`
- Nitro Version:    `0.5.4`
- Package Manager:  `npm@8.11.0`
- Builder:          `vite`
- User Config:      `-`
- Runtime Modules:  `-`
- Build Modules:    `-`
------------------------------

StackBlitz

Nuxi 3.0.0-rc.11                                                                                                                  14:30:00
RootDir: /home/projects/github-pdzf4a                                                                                             14:30:01
Nuxt project info:                                                                                                                14:30:01

------------------------------
- Operating System: `Linux`
- Node Version:     `v16.14.2`
- Nuxt Version:     `3.0.0-rc.11`
- Nitro Version:    `0.5.4`
- Package Manager:  `npm@7.17.0`
- Builder:          `vite`
- User Config:      `modules`
- Runtime Modules:  `@nuxt/content@2.1.1-27729314.5fc042b`
- Build Modules:    `-`
------------------------------

Reproduction

First noticed: https://github.com/michaelvcolianna/kiwisbybeat.net (findSurround is being used in /pages/[series]/[comic].vue)

Plain StackBlitz fork: https://stackblitz.com/edit/github-pdzf4a?file=pages%2F[...slug].vue

Expecting result

Returned array from findSurround has appropriate surrounding elements.

Actual result

Both elements of findSurround return array are null.

Describe the bug

Not sure if related to https://github.com/nuxt/content/issues/1235, a separate findSurround() issue, I'm interpreting the docs wrong, or my content folder isn't set up right, but I can't seem to get findSurround to locate a previous or next content.

I first noticed it in my repo with numbered docs, found 1235, and tried using content-edge with no change. Whether I query using route parameters or manually with strings, the returned array is always [null,null] – I tried paring down to just one dir with 3 docs, as well as removing numbering, which did not change anything.

The same issue happened after forking https://stackblitz.com/github/nuxt/starter/tree/content and creating a quick subdirectory with 3 docs. The catchall page has hard-coded query info but I also left the dynamic info above it, commented out.

I am not seeing any errors in the console output.

Additional context

I'm not sure why npx nuxi info output for my local machine doesn't list the modules I'm using, but here they are:

Logs

No response

farnabaz commented 2 years ago

Hey, Sorry for the late response The first argument of findSurround function should be full path of the target content. in your example it should be:

queryContent().findSurround('/test/part2')