bridge icon indicating copy to clipboard operation
bridge copied to clipboard

fix: handle functional `generate.routes`

Open danielroe opened this issue 2 years ago • 0 comments

🔗 Linked issue

resolves https://github.com/nuxt/bridge/issues/472

❓ Type of change

  • [ ] 📖 Documentation (updates to the documentation or readme)
  • [x] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ ] 👌 Enhancement (improving an existing functionality like performance)
  • [ ] ✨ New feature (a non-breaking change that adds functionality)
  • [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Users who want to programmatically determine what routes should be prerendered should use a hook to do so:

import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  hooks: {
    async 'nitro:config' (config) {
      const routes = await getRoutes()
      config.prerender.routes.push(...routes)
    }
  }
})

In the mean time, for backward compatibility, we can call the generate.routes function.

📝 Checklist

  • [x] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

danielroe avatar Aug 12 '22 15:08 danielroe