27 lines
799 B
Vue
27 lines
799 B
Vue
<script setup lang="ts">
|
|
import { useTemplateRegistry } from '#layers/composables/useTemplateRegistry'
|
|
import type { PageDataTemplate } from '#layers/types/api/pageData'
|
|
|
|
const props = defineProps<{ templates: PageDataTemplate[] }>()
|
|
const registry = useTemplateRegistry() as Record<string, { component: any }>
|
|
|
|
const isShowTemplate = (template: PageDataTemplate) => {
|
|
return template?.components && Object.keys(template.components).length > 0
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<main>
|
|
<template
|
|
v-for="(template, index) in props.templates"
|
|
:key="template.template_code ?? index"
|
|
>
|
|
<component
|
|
:is="registry[template.template_code]?.component"
|
|
v-if="isShowTemplate(template)"
|
|
:components="template.components"
|
|
/>
|
|
</template>
|
|
</main>
|
|
</template>
|