Files

44 lines
1.2 KiB
Vue
Raw Permalink Normal View History

2024-06-28 15:39:26 +07:00
<script lang="ts" setup>
2024-07-03 15:33:51 +07:00
import { Article_Section_Default, Article_Detail } from "./index";
2024-07-01 16:04:16 +07:00
import type { PageSection } from "@/server/models/dynamic-page/index";
2024-06-28 15:39:26 +07:00
import { enumPageSectionKey, enumPageSectionTemplate } from "@/definitions/enum";
const _props = defineProps<{
settings?: any;
content?: any;
section: PageSection;
}>();
const definedDynamicSection: Record<string, any> = {
2024-07-05 09:45:00 +07:00
[`${enumPageSectionTemplate[enumPageSectionKey.ARTICLE]["DEFAULT"]}`]: Article_Section_Default,
2024-07-03 15:33:51 +07:00
[`${enumPageSectionTemplate[enumPageSectionKey.ARTICLE]["DETAIL"]}`]: Article_Detail,
2024-06-28 15:39:26 +07:00
};
const getCurrentSection = computed(() => _props.settings.template);
const GET_PROPS = computed(() => {
return () => {
let props: any = {};
if (_props.settings) {
for (const [key, value] of Object.entries(_props.settings)) {
props = {
...props,
[key]: value,
};
}
}
return props;
};
});
</script>
<template>
2024-07-05 11:02:04 +07:00
<component
v-if="definedDynamicSection[getCurrentSection]"
:is="definedDynamicSection[getCurrentSection]"
v-bind="{ ...GET_PROPS(), section: _props.section, content: _props.content, settings: _props.settings }"
>
2024-06-28 15:39:26 +07:00
<slot />
</component>
</template>