Skip to content
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

Extend component meta #5168

Open
romhml opened this issue Feb 10, 2025 · 2 comments · May be fixed by #5169
Open

Extend component meta #5168

romhml opened this issue Feb 10, 2025 · 2 comments · May be fixed by #5169

Comments

@romhml
Copy link

romhml commented Feb 10, 2025

What problem does this feature solve?

It would be usefull for library authors to be able to extend component metas. In @nuxt/ui for example we're using something similar for our devtools, allowing us to pass default property values and examples to preview components (Here's an example).

What does the proposed solution look like?

We could define a new macro defineComponentMeta(meta: Record<string, any>) that can be used within a component. Its content would be parsed and injected into the component's meta by the meta checker.

<script setup lang="ts">
const props = defineProps<{ foo: string }>()

extendComponentMeta({
    bar: 'baz'
})
</script>

<template>
    <span />
</template>

Which would result in the following meta:

{
    bar: 'baz',
    props: [ /* ... */ ],
    // ...
}

I can look into the implementation if needed.

@KazariEX
Copy link
Collaborator

This requires runtime support (just drops it), you can try implementing this feature.

@romhml romhml linked a pull request Feb 10, 2025 that will close this issue
@romhml
Copy link
Author

romhml commented Feb 10, 2025

@KazariEX I submitted a draft implementation with some questions. I'll continue working on it and look into the runtime support too.

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 a pull request may close this issue.

2 participants