docs: add props

This commit is contained in:
Timothy Yin 2024-11-27 21:53:44 +08:00
parent a8e47c6bff
commit 8fefe70937
10 changed files with 133 additions and 8 deletions

View File

@ -0,0 +1,50 @@
<script lang="ts" setup>
import type { ComponentMeta } from 'vue-component-meta'
import { camelCase, upperFirst } from 'scule'
const route = useRoute()
const props = defineProps({
slug: {
type: String,
default: null,
},
})
const slug = props.slug || route.params.slug[route.params.slug.length - 1]
const componentCamelName = camelCase(slug)
const componentName = `Ray${upperFirst(componentCamelName)}`
const meta = await fetchComponentMeta(componentName)
const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => meta?.meta?.props || [])
</script>
<template>
<ProseTable>
<ProseThead>
<ProseTr>
<ProseTh>Prop</ProseTh>
<ProseTh>Default</ProseTh>
<ProseTh>Type</ProseTh>
</ProseTr>
</ProseThead>
<ProseTbody>
<ProseTr v-for="prop in metaProps" :key="prop.name">
<ProseTd>
{{ prop.name }}
</ProseTd>
<ProseTd>
<ProseCodeInline v-if="prop.default">
{{ prop.default }}
</ProseCodeInline>
</ProseTd>
<ProseTd>
<ProseCodeInline v-if="prop.type">
{{ prop.type }}
</ProseCodeInline>
<MDC v-if="prop.description" :value="prop.description" class="mt-1" />
</ProseTd>
</ProseTr>
</ProseTbody>
</ProseTable>
</template>

View File

@ -0,0 +1,26 @@
<script lang="ts" setup>
import { camelCase, upperFirst } from 'scule'
const route = useRoute()
const props = defineProps({
slug: {
type: String,
default: null,
},
})
const slug = props.slug || route.params.slug[route.params.slug.length - 1]
const componentCamelName = camelCase(slug)
const componentName = `Ray${upperFirst(componentCamelName)}`
const meta = await fetchComponentMeta(componentName)
</script>
<template>
<div class="flex flex-col not-prose font-mono divide-y divide-gray-100 dark:divide-gray-800">
<div v-for="(slot, k) in meta?.meta?.slots" :key="k" class="py-2">
<pre>{{ slot }}</pre>
</div>
</div>
</template>

View File

@ -114,7 +114,14 @@ props:
Button
::
## Config
## API
### Props
::ComponentProps
::
### Config
::ComponentDefaults
::

View File

@ -142,7 +142,14 @@ const modal = ref<string>("");
</template>
```
## Config
## API
### Props
::ComponentProps
::
### Config
::ComponentDefaults
::

View File

@ -44,7 +44,14 @@ props:
K
::
## Config
## API
### Props
::ComponentProps
::
### Config
::ComponentDefaults
::

View File

@ -82,7 +82,14 @@ slots:
:RayButton{icon="tabler:message" label="messages" color="invert"}
::
## Config
## API
### Props
::ComponentProps
::
### Config
::ComponentDefaults
::

View File

@ -60,7 +60,14 @@ props:
---
::
## Config
## API
### Props
::ComponentProps
::
### Config
::ComponentDefaults
::

View File

@ -176,7 +176,14 @@ const modal = ref<string>("");
</template>
```
## Config
## API
### Props
::ComponentProps
::
### Config
::ComponentDefaults
::

View File

@ -63,7 +63,14 @@ props:
---
::
## Config
## API
### Props
::ComponentProps
::
### Config
::ComponentDefaults
::

View File

@ -60,7 +60,7 @@ export default defineNuxtConfig({
type: false,
props: true,
slots: true,
events: false,
events: true,
exposed: false,
},
},