Revert "docs(ComponentCode/ComponentExample): use relative imports"

This reverts commit d75f47419d.
This commit is contained in:
Benjamin Canac
2024-11-19 15:54:51 +01:00
parent fa9f0a7e2a
commit 5deadc7096
2 changed files with 3 additions and 9 deletions

View File

@@ -43,8 +43,7 @@ const { $prettier } = useNuxtApp()
const camelName = camelCase(props.slug ?? route.params.slug?.[route.params.slug.length - 1] ?? '')
const name = `U${upperFirst(camelName)}`
const component = defineAsyncComponent(() => import(`../../../../src/runtime/components/${upperFirst(camelName)}.vue`))
const component = defineAsyncComponent(() => import(`#ui/components/${upperFirst(camelName)}.vue`))
const componentProps = reactive({ ...(props.props || {}) })
const componentEvents = reactive({

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { upperFirst, camelCase } from 'scule'
import { camelCase } from 'scule'
import { get, set } from '#ui/utils'
const props = withDefaults(defineProps<{
@@ -52,16 +52,11 @@ const slots = defineSlots<{
}>()
const { $prettier } = useNuxtApp()
const route = useRoute()
const camelName = camelCase(props.name)
const data = await fetchComponentExample(camelName)
const dir = route.params.slug?.[route.params.slug.length - 1]
const component = defineAsyncComponent(() => import(`./examples/${dir}/${upperFirst(camelName)}.vue`))
const componentProps = reactive({ ...(props.props || {}) })
const code = computed(() => {
@@ -175,7 +170,7 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {
</div>
<div class="flex justify-center p-4" :class="props.class">
<component :is="component" v-bind="{ ...componentProps, ...optionsValues }" />
<component :is="camelName" v-bind="{ ...componentProps, ...optionsValues }" />
</div>
</div>
</template>