ContentNavigation doesn't seem to use the :query ?
See original GitHub issueEnvironment
Nuxi 3.0.0-rc.11 01:01:15 RootDir: /Users/mathieu/nsinuxt 01:01:15 Nuxt project info: (copied to clipboard) 01:01:15
- Operating System:
Darwin
- Node Version:
v18.9.0
- Nuxt Version:
3.0.0-rc.11
- Nitro Version:
0.5.4
- Package Manager:
npm@8.19.2
- Builder:
vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Reproduction
in pages/[…slug].vue :
<template>
<div>
<ContentNavigation v-slot="{ navigation }" :query="querpath">
<NuxtLayout :navigation="navigation">
<div class="basis-1/2 shrink grow"><ContentDoc /></div>
</NuxtLayout>
</ContentNavigation>
</div>
</template>
<script setup>
const querpath = queryContent('snt');
</script>
Describe the bug
I want to generate a nav sidebar where I only load the files which are in the same folder as the current page. For this example, I hardcoded “snt” but first I used useRoute() to get the path, then split & concat to get only the first element of the path (in the content folder, there’s two folders : snt and nsi) So I get this ContentNavigation from the catch-all route, then I pass it to the layout, and the layout passes it to the nav sidebar component.
It looks like the ContentNavigation component returns in the navigation variable the tree from the root of the content folder, without taking my “snt” query param.
Maybe my call to ContentNavigation from the catch-all route is not a good practice ?
Additional context
^ From the “localhost:3000/snt” URL ^
I tried the same code directly in the nav sidebar component, and I get the same result : navigation from the root of the content folder.
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
I see, this happens because the argument of
queryContent
affects only when you usefind/findeOne
.To use query builder for navigation you can manually use where
Okay, here, the bug is reproduced. Well I don’t know if it’s a bug or not, but the navigation doesn’t take the :query and gives me the items from the root of the contents folder.
https://stackblitz.com/edit/github-vdnwzv-1qzrty?file=components%2Fsidebar.vue,pages%2F[...slug].vue