akhtarabbas5
akhtarabbas5
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai it says [GET] "/api/routes": <no response> Failed to parse URL from /api/routes when I run npm run generate
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai can we define an api in server and set that to prerenderer to get routes?
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai all the above solutions are not working with nuxt 3.12.3 and nuxt/content 3.3.0
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@here need help as none of the above are working
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai I don't want to use http://localhost:3000 in the API and if I only use pre-renderer then I will not be able to set components for different pages
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai and when I add this in utils and try to generate routes from nuxt config I get queryCollection is not defined utils/generateRoutes.js export async function generateRoutes() { // Fetch content from different collections const blogs = await queryCollection('blog').all() const routes = [] // Add parent page routes blogs.forEach(blog => { const url = blog.path.replace(/^/blogs/, ""); routes.push({ name: blog-${url}, path: url, file: '~/views/Blog.vue' }) }) return routes } nuxt.config.ts import { generateRoutes } from "./utils/generateRoutes" ... hooks: { async 'pages:extend'(pages) { const routes = await generateRoutes() pages.push(...routes) } }, ...
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai in the following code it says queryCollection is not defined export default defineNuxtPlugin(async (nuxtApp) => { const {queryCollection} = nuxtApp const communities = await queryCollection('communities').select('slug').all() const events = await queryCollection('events').select('communitySlug', 'slug').all() const news = await queryCollection('news').select('communitySlug', 'slug').all() nuxtApp.hooks.hook('prerender:routes', (routes) => { communities.forEach((community) => { const communityPath = /community/${community.slug}; routes.push(${communityPath}/events); routes.push(${communityPath}/news); }) events.forEach((event) => { routes.push(/community/${event.communitySlug}/events/${event.slug}); }) news.forEach((newsItem) => { routes.push(/community/${newsItem.communitySlug}/news/${newsItem.slug}); }) return routes }) })
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai can you provide the updated code and show me how to use a server endpoint to generate routes. I am using the queryCollection in this // utils/generate-routes.ts import { queryCollection } from '@nuxt/content' export async function generateRoutes() { // Fetch content from different collections const parentPages = await queryCollection('blog').find() const routes = [] // Add parent page routes parentPages.forEach(page => { routes.push({ name: parent-${page.slug}, path: /${page.slug}, file: '~/views/Blog.vue' }) }) return routes }
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai it says [unhandledRejection] (0 , _content.queryCollection) is not a function , note that I am using nuxt/content v3.1.1
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai I am using nuxt/content module but I don't want the sitemap to generate URLs according to folder structure in content directory as I have same URL structures for different pages and therefore I am generating routes and adding them in pages:extend hook, so can I use the same function I am using to pre-render the routes in sitmemap to add routes
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
also will all those route get generated in sitemap? @kapa.ai
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai can I get files from different folders in content directory and then return an array of object which will statify the URLS I want and use those in the pages:extend hook. like in a seperate file can I get the files from different content directories or from different collection and define structure like this in routes.ts [ { name: ${slug}, path: /${slug}, file: '~views/blog.vue', }, { name: ${slug}, path: /${slug}, file: '~views/testimonial.vue', } ] and then use this in nuxt.config.ts hooks: { async 'pages:extend'(pages) { const routesFilePath = path.resolve(__dirname, '/routes.ts'); const routesModule = await import(routesFilePath); const routes = routesModule.default; pages.push(...routes); } },
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai I think it will effect the preformence as well have a lot of subdirectories in the content folder and and one another issue is we don't know how many files we will have so it's not possbile to add each url in nuxt.config
72 replies
NNuxt
Created by akhtarabbas5 on 2/25/2025 in #❓・help
Custom Routing in Nuxt 3 with Nuxt/content 3
@kapa.ai but it will not render the page as the slug will be test-training but the .md file for it will be under /training folder
72 replies