minhnt-dev: oonly ssr fix
This commit is contained in:
@@ -2,18 +2,21 @@
|
||||
import DynamicTemplate from "~/components/dynamic-page/page/templates/index.vue";
|
||||
import DynamicSection from "~/components/dynamic-page/page-section/templates/index.vue";
|
||||
import { useDynamicPageStore } from '~/stores/dynamic-page';
|
||||
const { currentPage, sectionPublished, componentPublished } = storeToRefs(useDynamicPageStore());
|
||||
|
||||
const route = useRoute();
|
||||
const store = reactive({
|
||||
dynamicPage: useDynamicPageStore(),
|
||||
});
|
||||
|
||||
await useAsyncData('index', () => store.dynamicPage.fetchPageByCode(route.path.replace('/', '')))
|
||||
const { data } = await useAsyncData('index', () => store.dynamicPage.fetchPageByCode(route.path.replace('/', '')))
|
||||
const asycnCurrentPage = data.value.currentPage;
|
||||
const asycnSectionPublished = data.value.sectionPublished;
|
||||
const asycnComponentPublished = data.value.componentPublished;
|
||||
|
||||
useHead({
|
||||
title: () => currentPage.value.title || '',
|
||||
title: () => asycnCurrentPage.title || '',
|
||||
description: () => 'Với công nghệ đột phá và giải pháp sáng tạo, Vpress sẽ là đối tác tin cậy của các tòa soạn báo, cùng nhau kiến tạo nên những giá trị bền vững trong kỷ nguyên chuyển đổi số báo chí.',
|
||||
ogTitle: () => currentPage.value.title || '',
|
||||
ogTitle: () => asycnCurrentPage.title || '',
|
||||
ogImage: () => '~/assets/images/thumbnail.jpg',
|
||||
ogDescription: () => 'Với công nghệ đột phá và giải pháp sáng tạo, Vpress sẽ là đối tác tin cậy của các tòa soạn báo, cùng nhau kiến tạo nên những giá trị bền vững trong kỷ nguyên chuyển đổi số báo chí.',
|
||||
twitterCard: () => 'summary_large_image',
|
||||
@@ -21,10 +24,10 @@ useHead({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="h-screen" v-if="currentPage">
|
||||
<DynamicTemplate :settings="currentPage.settings">
|
||||
<main class="h-screen" v-if="asycnCurrentPage">
|
||||
<DynamicTemplate :settings="asycnCurrentPage.settings">
|
||||
<DynamicSection
|
||||
v-for="(section, index) in sectionPublished"
|
||||
v-for="(section, index) in asycnSectionPublished"
|
||||
:key="index"
|
||||
:settings="section.settings"
|
||||
:content="section.content ? JSON.parse(section.content) : null"
|
||||
@@ -32,4 +35,4 @@ useHead({
|
||||
/>
|
||||
</DynamicTemplate>
|
||||
</main>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user