-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/custom-cart
- Loading branch information
Showing
5 changed files
with
29 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,20 @@ | ||
<template> | ||
<div> | ||
<VPBuilderIO v-if="isBulderIOContent" :content="pageDocumentContent?.content" /> | ||
<VPBuilderIO v-if="isBulderIOContent" :content="pageDocument?.content" /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computedEager } from "@vueuse/core"; | ||
import { computed, watch, watchEffect } from "vue"; | ||
import { useSlugInfo } from "@/shared/common"; | ||
import { computed } from "vue"; | ||
import VPBuilderIO from "@/pages/matcher/virto-pages/vp-builder-io.vue"; | ||
import type { StateType } from "@/pages/matcher/priorityManager"; | ||
interface IProps { | ||
pathMatch?: string[]; | ||
isVisible?: boolean; | ||
// pageDocument: { id: string; source?: string; permalink?: string; content: string } | null; | ||
} | ||
interface IEmits { | ||
(event: "setState", value: StateType): void; | ||
pageDocument: { id: string; source?: string; permalink?: string; content: string } | null; | ||
} | ||
const props = defineProps<IProps>(); | ||
const emit = defineEmits<IEmits>(); | ||
const seoUrl = computedEager(() => { | ||
if (!props.pathMatch) { | ||
return "/"; | ||
} | ||
// Because URL `/printers/` is an array of paths ["printers", ""], empty paths must be removed. | ||
const paths = props.pathMatch.filter(Boolean); | ||
return paths.join("/"); | ||
}); | ||
const { | ||
loading, | ||
slugInfo, | ||
objectType, | ||
hasPageDocumentContent, | ||
pageDocumentContent, | ||
fetchPageDocumentContent, | ||
} = useSlugInfo(seoUrl); | ||
const isBulderIOContent = computed(() => { | ||
return objectType.value === "Pages" | ||
&& hasPageDocumentContent.value | ||
&& pageDocumentContent.value?.source === "builder.io"; | ||
return props.pageDocument?.source === "builder.io"; | ||
}); | ||
watchEffect(() => { | ||
if (loading.value) { | ||
emit("setState", "loading"); | ||
} else if (pageDocumentContent.value) { | ||
emit("setState", "ready"); | ||
} else { | ||
emit("setState", "empty"); | ||
} | ||
}); | ||
watch(slugInfo, () => { | ||
const type = slugInfo.value?.entityInfo?.objectType; | ||
if (type === 'Pages') { | ||
void fetchPageDocumentContent(); | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters