-
Notifications
You must be signed in to change notification settings - Fork 102
/
_.vue
69 lines (64 loc) · 1.51 KB
/
_.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<template>
<div :key="$route.path" style="min-height: 55vh">
<component
:is="getComponent"
:cms-page="cmsPage"
:page="staticPage"
:error="staticError"
/>
</div>
</template>
<script>
import { useCms } from "@shopware-pwa/composables";
import { ref, provide } from "vue-demi";
export default {
name: "DynamicRoute",
components: {},
setup() {
const { page, error, loading, metaTitle, metaDescription, metaKeywords, pageTitle } = useCms();
const cmsPage = ref(page.value?.cmsPage);
const staticPage = ref(page.value);
const staticError = ref(error.value);
provide("cms-page", page);
const getComponent = () => {
if (staticPage.value) {
return () =>
import("@/components/views/" + page.value.resourceType + ".vue");
}
if (staticError.value)
return () => import("@/components/views/error.page.vue");
};
return {
staticPage,
cmsPage,
staticError,
loading,
getComponent: getComponent(),
metaObject: computed(() => [
{
hid: "title",
name: "title",
content: metaTitle.value
},
{
hid: "description",
name: "description",
content: metaDescription.value
},
{
hid: "keywords",
name: "keywords",
content: metaKeywords.value
}
]),
pageTitle,
};
},
head() {
return {
title: this.pageTitle,
meta: this.metaObject
}
}
};
</script>