2024-05-31 00:46:43 +07:00
|
|
|
/*
|
|
|
|
|
- LayoutType: None=0 | Normal=1 | Short=2 | Long=3 | Page=4 | Other=5
|
|
|
|
|
- ContentType: None=0 | Normal=1 | Photo=2 | Video=3 | Graphic=4 | Document=5 | Reaction=6 (Poll,Quiz) | Other=7
|
|
|
|
|
- Type: None=0 | Editorial=1 | General=2 | Reportage=3 | Interview=4 | Survey=5 | Tutorial=6 | Podcast=7 | Broadcast=8 | TalkShow=9 | LiveStream=10 | Translation=11 | Promotion=12 | Other=13
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import DynamicTemplate from "~/components/dynamic-page/page/templates/index.vue";
|
|
|
|
|
import DynamicSection from "~/components/dynamic-page/page-section/templates/index.vue";
|
|
|
|
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
|
|
|
|
import { useDynamicPageStore } from '~/stores/dynamic-page';
|
|
|
|
|
import { useArticleStore } from '~/stores/articles';
|
|
|
|
|
const { currentPage, sectionPublished, componentPublished } = storeToRefs(useDynamicPageStore());
|
|
|
|
|
const { currentArticle } = storeToRefs(useArticleStore());
|
2024-06-03 10:24:28 +07:00
|
|
|
|
2024-05-31 00:46:43 +07:00
|
|
|
const store = reactive({
|
|
|
|
|
dynamicPage: useDynamicPageStore(),
|
|
|
|
|
article: useArticleStore(),
|
|
|
|
|
});
|
2024-05-31 12:39:53 +07:00
|
|
|
|
2024-06-21 09:56:34 +07:00
|
|
|
const loadPage = async () => {
|
|
|
|
|
const promises = [];
|
|
|
|
|
promises.push(store.article.getArticleBySlug(route.params.slug));
|
2024-05-31 00:46:43 +07:00
|
|
|
|
2024-06-21 09:56:34 +07:00
|
|
|
let isContentType = '';
|
2024-05-31 00:46:43 +07:00
|
|
|
switch (currentArticle.value?.contentType) {
|
|
|
|
|
case 1:
|
2024-06-21 09:56:34 +07:00
|
|
|
isContentType = 'trang-chi-tiet-bai-viet-general';
|
|
|
|
|
break;
|
2024-05-31 00:46:43 +07:00
|
|
|
case 2:
|
2024-06-21 09:56:34 +07:00
|
|
|
isContentType = 'trang-chi-tiet-bai-viet-image';
|
|
|
|
|
break;
|
2024-05-31 00:46:43 +07:00
|
|
|
case 3:
|
2024-06-21 09:56:34 +07:00
|
|
|
isContentType = 'trang-chi-tiet-podcast';
|
|
|
|
|
break;
|
2024-05-31 00:46:43 +07:00
|
|
|
case 4:
|
2024-06-21 09:56:34 +07:00
|
|
|
isContentType = 'trang-chi-tiet-bai-viet-video';
|
|
|
|
|
break;
|
2024-05-31 00:46:43 +07:00
|
|
|
case 5:
|
2024-06-21 09:56:34 +07:00
|
|
|
if (currentArticle.value?.layoutType === 4) {
|
|
|
|
|
isContentType = 'trang-chi-tiet-bai-viet-emagazine';
|
2024-05-31 15:31:05 +07:00
|
|
|
break;
|
2024-06-21 09:56:34 +07:00
|
|
|
}
|
|
|
|
|
if (currentArticle.value?.layoutType === 3) {
|
|
|
|
|
isContentType = 'trang-chi-tiet-bai-viet-infographics';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
isContentType = 'trang-chi-tiet-bai-viet-general';
|
|
|
|
|
break;
|
2024-05-31 00:46:43 +07:00
|
|
|
}
|
2024-06-21 09:56:34 +07:00
|
|
|
promises.push(store.dynamicPage.fetchPageByCode(isContentType));
|
|
|
|
|
await Promise.all(promises);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await useAsyncData('detail-article', () => loadPage());
|
2024-05-31 00:46:43 +07:00
|
|
|
|
|
|
|
|
useSeoMeta({
|
2024-06-03 10:24:28 +07:00
|
|
|
title: () => currentArticle.value?.title?.replace(/<[^>]+>/g, ''),
|
|
|
|
|
description: () => currentArticle.value?.intro,
|
|
|
|
|
ogTitle: () => currentArticle.value?.title,
|
|
|
|
|
ogImage: () => currentArticle.value?.thumbnail,
|
|
|
|
|
ogDescription: () => currentArticle.value?.intro,
|
2024-06-21 09:56:34 +07:00
|
|
|
twitterCard: () => 'summary_large_image',
|
2024-05-31 00:46:43 +07:00
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-05-31 12:39:53 +07:00
|
|
|
<main class="h-screen" v-if="currentPage && currentPage.settings">
|
2024-05-31 00:46:43 +07:00
|
|
|
<DynamicTemplate :settings="currentPage.settings">
|
|
|
|
|
<template v-if="sectionPublished && sectionPublished.length > 0">
|
|
|
|
|
<DynamicSection
|
|
|
|
|
v-for="(section, index) in sectionPublished"
|
|
|
|
|
:key="index"
|
|
|
|
|
:settings="section.settings"
|
|
|
|
|
:content="section.content ? JSON.parse(section.content) : null"
|
|
|
|
|
:section="section"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</DynamicTemplate>
|
|
|
|
|
</main>
|
2024-06-21 09:56:34 +07:00
|
|
|
</template>
|