-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nuxt-component-meta
for Vue3
#321
Comments
@Tahul Should this be included in the |
I believe so, I would also have thoughts of @pi0, @antfu and @danielroe regarding this. The idea behind this is to expose the list of Nuxt components the project has in order to include them in the Milkdown editor, similar to Docus (was using Vue 2): http://volta.s3.fr-par.scw.cloud/Screenshot_2022_04_14_at_16_27_21_9b3be3c68a.mp4 In the video, you can see the props and slots of this component: https://github.com/benjamincanac/docus-starter/blob/main/components/hero/Hero.vue @farnabaz did the work on https://www.npmjs.com/package/nuxt-component-meta for Nuxt 2 / Vue 2 but I am wondering how we can support it for Vue 3? |
We already have a list: import { componentNames } from '#build/components'
console.log(componentNames) See nuxt/framework#4150 for more information. (It's also possible to import components directly from that file, e.g. |
As I quickly checked, seems that |
What about testing something like https://github.com/vuedx/languagetools/tree/main/packages/compiler-sfc ? The goal here @danielroe is that Nuxt Admin is running not in the user's project. @farnabaz do we have the format of what we exposed in Nuxt 2 for the editor? |
If you need additional meta such as props other than name I believe |
In the longer term, btw we also need this for dev tools. Once you had a working version of component-meta for Nuxt 3, would be nice to discuss if we can expose it as a (lazy) function from nuxt 3 components. Having an external module would be helpful to avoid reinventing the wheel. |
Fully agree, the code shall be able to be shared for both admin and devtools. This is a first attempt: https://stackblitz.com/edit/nuxt-starter-jzedtw?file=nuxt.config.ts It seems that I cannot get the props that easily, but is worth exploring since we shall use the official vue SFC compiler. |
What are the fields we are expecting? |
Exactly! I thought we could also maybe use Volar internal packages to achieve that? Maybe we could also support I know it parses slots & props nicely for Vue 3! |
@kevinmarrec can you confirm the fields we need for Milkdown editor? Current work done by @farnabaz is on nuxtlabs/nuxt-component-meta#17, do you need any help? |
I don’t know if there is better way to extract extract prop types and defaults, rather than walking through AST tree or not. @antfu maybe you have some ideas about the extraction or other possible solutions. nuxtlabs/nuxt-component-meta#17 |
Our editor is expecting an array of ComponentSchema. A schema is a definition of a component, which includes its |
@kevinmarrec I just release v0.1.0, It misses some data about props but general schema should be same. https://github.com/nuxtlabs/nuxt-component-meta Ping me if anything goes wrong |
Thank you @farnabaz! |
The project should expose a route with parsed components (as json)
The text was updated successfully, but these errors were encountered: