Skip to content

feat: introduce component parser utility #84

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

Merged
merged 6 commits into from
Jul 21, 2025
Merged

Conversation

farnabaz
Copy link
Collaborator

@farnabaz farnabaz commented Jul 10, 2025

This PR introduces two utilities to parse and worked with components:

  • import { getComponentMeta } from 'nuxt-component-meta/parser': receives a component(path), parse it and return component meta data
  • import { propsToJsonSchema } from 'nuxt-component-meta/utils': receives props metadata of a component, which is generated by getComponentMeta, and converts metadata to JSON Schema.

resolves #83

Combination of propsToJsonSchema and json-schema-to-zod package can be used to generate Zod validation schema from a component props.

Copy link

pkg-pr-new bot commented Jul 10, 2025

npm i https://pkg.pr.new/nuxt-component-meta@84

commit: fd1abe7

@farnabaz
Copy link
Collaborator Author

@Mw3y feel free to test them

@Mw3y
Copy link

Mw3y commented Jul 10, 2025

Thanks!

@Mw3y
Copy link

Mw3y commented Jul 10, 2025

Hey @farnabaz,

I'm currently trying to use it inside the components:extend hook to generate my LaTeX xparse definitions. Overall this works great but in my case the component param is the fullPath. The cachePath will therefore be wrong. Also, rootDir should be optional (to be able to only pass cache: true).

Also, the NuxtWelcome component is not being found because for some reason its filePath doesn't include a .vue file extension.

Is there an easier way to use your changes inside components:extend?

@farnabaz
Copy link
Collaborator Author

@Mw3y Thanks for the feedback, I'm working on cache and performance. Also good to know bout NuxtWelcome I'll dig.

@farnabaz farnabaz changed the title fea: introduce component parser utility feat: introduce component parser utility Jul 21, 2025
@farnabaz farnabaz merged commit 3d47c20 into main Jul 21, 2025
3 checks passed
@farnabaz farnabaz deleted the feat/single-parser branch July 21, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support generating Zod schemas from component meta JSON
2 participants