Files

43 lines
1.1 KiB
Vue
Raw Permalink Normal View History

2024-05-30 18:06:50 +07:00
<script lang="ts" setup>
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 } from "@/definitions/enum";
2024-07-05 09:45:00 +07:00
import { None_Section,Category_Section, Article_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-07-05 09:45:00 +07:00
[enumPageSectionKey.CATEGORY]: Category_Section,
2024-07-03 15:33:51 +07:00
[enumPageSectionKey.ARTICLE]: Article_Section,
2024-06-28 15:39:26 +07:00
};
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-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>
2024-05-30 18:06:50 +07:00
</template>