nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 628 forks source link

Get md all components names #2099

Open productdevbook opened 1 year ago

productdevbook commented 1 year ago

Is your feature request related to a problem? Please describe

I need to compile the used component names, but I can't access the nitro module I wrote for this defined Nuxt Module.

Describe the solution you'd like

https://github.com/nuxt/content/blob/0fb0d6333c6bf59fd15849c3c5cb17879a404aba/src/runtime/transformers/component-resolver.ts#L38-L49

Is it possible to write a structure that will freeze the names of the components here?

  nitroApp.hooks.hook('content:file:afterParse', async (content) => {
    console.log('content:file:afterParse', content._components)

this empty

atinux commented 1 year ago

It's only used on client-side right now, why do you need them?

productdevbook commented 1 year ago

I will use it to import components for md. I don't want to use component/content. I think it would be faster to put 500 components component/content and a addComponent using only 20 components.

after used

  addComponent({
              name: item.name,
              global: true,
              filePath: resolve(runtimeDir, 'components', `${item.name}.vue`),
              priority: 0,
            })