Skip to content

Commit

Permalink
Support preview on information pages (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
walsh9 authored Feb 13, 2023
1 parent 7f7c52f commit b456ebd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
20 changes: 17 additions & 3 deletions pages/[sectionSlug]/index.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
<script setup lang="ts">
import { InformationPage } from '../../composables/types/Page'
/* preview */
import { usePreviewData } from '~/composables/states'
const previewData = usePreviewData()
const route = useRoute()
const page = await findPage(route?.params?.sectionSlug as string).then(
({ data }) => normalizeFindPageResponse(data)
)
const isPreview = route.query.preview ? true : false
/* preview */
let page
if (isPreview)
{
console.log(previewData)
page = previewData.value.data
}
else {
page = await findPage(route?.params?.sectionSlug as string).then(
({ data }) => normalizeFindPageResponse(data)
)
}
</script>
<template>
<div>
Expand Down
6 changes: 3 additions & 3 deletions pages/preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const handlePreviewData = () => {
}
watch(previewData, (res) => {
const url = new URL(previewData.value.data?.url || fetchData.value.url)
const path = url.pathname
switch (fetchData.value.meta.type) {
case 'news.ArticlePage':
return navigateTo(
Expand All @@ -40,11 +42,9 @@ watch(previewData, (res) => {
case 'tagpages.TagPage':
return navigateTo(`/tags/${identifierId}?preview=true`)
case 'gallery.GalleryPage':
const url = new URL(previewData.value.data.url)
const path = url.pathname
return navigateTo(`${path}?preview=true`)
case 'standardpages.InformationPage':
break
return navigateTo(`${path}?preview=true`)
default:
break
}
Expand Down

0 comments on commit b456ebd

Please sign in to comment.