Files
NSG_PORTAL_V2/components/dynamic-page/page-section/templates/index.vue
T

41 lines
957 B
Vue
Raw Normal View History

2024-05-30 18:06:50 +07:00
<script lang="ts" setup>
2024-06-28 15:39:26 +07:00
import type { PageSection } from "@/models/cms";
import { enumPageSectionKey } from "@/definitions/enum";
import { None_Section } from "./index";
2024-05-30 18:06:50 +07:00
const _props = defineProps<{
2024-06-28 15:39:26 +07:00
settings?: any;
content?: any;
section?: any;
}>();
2024-05-30 18:06:50 +07:00
const definedDynamicSection: Record<string, any> = {
2024-06-28 15:39:26 +07:00
[enumPageSectionKey.NONE]: None_Section,
};
2024-06-17 11:48:00 +07:00
2024-06-28 15:39:26 +07:00
const getCurrentSection = computed(() => {
return _props.section?.taxonomy;
});
2024-05-30 18:06:50 +07:00
const GET_PROPS = computed(() => {
2024-06-28 15:39:26 +07:00
return () => {
let props: any = {};
if (_props.settings) {
for (const [key, value] of Object.entries(_props.settings)) {
props = {
...props,
[key]: value,
};
}
}
return props;
};
});
2024-05-30 18:06:50 +07:00
</script>
<template>
2024-06-28 15:39:26 +07:00
<component :is="definedDynamicSection[getCurrentSection]" v-bind="{ ...GET_PROPS(), section: _props.section, content: _props.content, settings: _props.settings }">
<slot />
</component>
2024-05-30 18:06:50 +07:00
</template>