Skip to content

Extend component meta #5168

Open
@romhml

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions