Nuxt.js 3 Upload component from headless CMS

Viewed 77

I would like to know what is the best way to perform a dynamic import of component in my case.

We create components and we get their data from an API to create the pages content. API look like this:

{
  "id": 128272,
  "code": "firstComponent",
  "content": []
},
{
   "id": 128272,
   "code": "secondComponent",
   "content": []
},

I read that can use dynamic component to load created components, and add it using resolveComponent()

<component :is="" />

As we can't know at first the list of component used in a page, should I import them all in defineNuxtConfig ?


Project deep dive,

  • pages /press/_slug give choices between ten components on our CMS
  • pages /video/_slug only 5 of them
  • and landing pages (_.vue) allow to use them all (20)
0 Answers
Related