fix: preview page transitions

This commit is contained in:
DIYgod
2023-03-03 22:49:39 +00:00
parent 34ae9421e2
commit 78e873591e
3 changed files with 31 additions and 2 deletions
+1 -1
View File
@@ -120,7 +120,7 @@ export const PostMeta: React.FC<{
</UniLink>
)}
</div>
{!(summary.isSuccess && !summary.data) && (
{(summary.isLoading || summary.data) && (
<div className="border rounded-xl mt-4 p-4 space-y-2">
<div className="font-bold text-zinc-700 flex items-center">
<LightBulbIcon className="inline w-4 h-4 mr-2 stroke-[2]" />
+4 -1
View File
@@ -18,6 +18,7 @@ export const getServerSideProps = async (
take?: number
useStat?: boolean
skipPages?: boolean
preview?: boolean
},
) => {
const domainOrSubdomain = ctx.params!.site as string
@@ -39,7 +40,9 @@ export const getServerSideProps = async (
queryClient,
),
new Promise(async (resolve, reject) => {
if (pageSlug) {
if (options?.preview) {
// do nothing
} else if (pageSlug) {
try {
const page = await fetchGetPage(
{
+26
View File
@@ -4,6 +4,32 @@ import { useGetPage } from "~/queries/page"
import type { ReactElement } from "react"
import { useRouter } from "next/router"
import { useGetSite } from "~/queries/site"
import { GetServerSideProps } from "next"
import { getServerSideProps as getLayoutServerSideProps } from "~/components/site/SiteLayout.server"
import { serverSidePropsHandler } from "~/lib/server-side-props"
import { QueryClient } from "@tanstack/react-query"
export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
async (ctx) => {
const queryClient = new QueryClient()
const domainOrSubdomain = ctx.params!.site as string
const { props: layoutProps } = await getLayoutServerSideProps(
ctx,
queryClient,
{
preview: true,
},
)
return {
props: {
...layoutProps,
domainOrSubdomain,
},
}
},
)
function SitePagePage() {
const router = useRouter()