@@ -32,7 +32,8 @@ const props = defineProps<{
3232const route = useRoute ()
3333const { $prettier } = useNuxtApp ()
3434
35- const camelName = camelCase (route .params .slug [route .params .slug .length - 1 ])
35+ const slug = Array .isArray (route .params .slug ) ? route .params .slug [0 ] ?? ' ' : route .params .slug ?? ' '
36+ const camelName = camelCase (slug [slug .length - 1 ] ?? ' ' )
3637const name = ` U${upperFirst (camelName )} `
3738
3839const componentProps = reactive ({ ... (props .props || {}) })
@@ -45,11 +46,11 @@ function setComponentProp(name: string, value: any) {
4546 set (componentProps , name , value )
4647}
4748
48- const componentTheme = theme [camelName ]
49+ const componentTheme = ( theme as any ) [camelName ]
4950const meta = await fetchComponentMeta (name as any )
5051
51- function mapKeys(obj , parentKey = ' ' ) {
52- return Object .entries (obj || {}).flatMap (([key , value ]) => {
52+ function mapKeys(obj : object , parentKey = ' ' ): any {
53+ return Object .entries (obj || {}).flatMap (([key , value ]: [ string , any ] ) => {
5354 if (typeof value === ' object' && ! Array .isArray (value )) {
5455 return mapKeys (value , key )
5556 }
@@ -63,11 +64,11 @@ function mapKeys(obj, parentKey = '') {
6364const options = computed (() => {
6465 const keys = mapKeys (props .props || {})
6566
66- return keys .map ((key ) => {
67+ return keys .map ((key : string ) => {
6768 const prop = meta ?.meta ?.props ?.find ((prop : any ) => prop .name === key )
6869 const propItems = get (props .items , key , [])
6970 const items = propItems .length
70- ? propItems .map (item => ({
71+ ? propItems .map (( item : any ) => ({
7172 value: item ,
7273 label: item
7374 }))
@@ -253,7 +254,7 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${JSON.stringif
253254 <component :is =" name" v-bind =" componentProps" @update:model-value =" !!componentProps.modelValue && setComponentProp('modelValue', $event)" >
254255 <template v-for =" slot in Object .keys (slots || {})" :key =" slot " #[slot ]>
255256 <ContentSlot :name =" slot" unwrap =" p" >
256- {{ slots[slot] }}
257+ {{ slots?. [slot] }}
257258 </ContentSlot >
258259 </template >
259260 </component >
0 commit comments