Grester
Grester
NNuxt
Created by Grester on 10/18/2024 in #❓・help
Nuxt Content Directory indexing too much?
To those interested, what I ended up doing is something similar to this (I also had to do this for prev/next pages, you just have to adapt to it ignore pages where _stem ends in index)
const {page} = useContent()
const trimmedPath = page.value?._path?.substring(0, page.value._path.lastIndexOf("/")) || "";

const [prev, next] = await queryContent()
.where({'_path':{$contains: trimmedPath, $ne: trimmedPath }})
.only(['_path', 'title'])
.sort({ date: 1 })
.where({ isArchived: false || undefined })
.findSurround(page.value._path||"/")
</script>
const {page} = useContent()
const trimmedPath = page.value?._path?.substring(0, page.value._path.lastIndexOf("/")) || "";

const [prev, next] = await queryContent()
.where({'_path':{$contains: trimmedPath, $ne: trimmedPath }})
.only(['_path', 'title'])
.sort({ date: 1 })
.where({ isArchived: false || undefined })
.findSurround(page.value._path||"/")
</script>
2 replies