properly ssr pages

This commit is contained in:
EGOIST 2022-05-09 00:08:03 +08:00
parent 991ab18115
commit c64a23d8ec
3 changed files with 12 additions and 9 deletions

View File

@ -2,8 +2,11 @@ import Link from "next/link"
import { formatDate } from "~/lib/date"
export const SiteArchives: React.FC<{
posts: { id: string; publishedAt: string; slug: string; title: string }[]
posts:
| { id: string; publishedAt: string; slug: string; title: string }[]
| undefined
}> = ({ posts }) => {
if (!posts) return null
return (
<>
<h2 className="text-xl font-bold page-title">Archives</h2>

View File

@ -20,7 +20,11 @@ export const getServerSideProps: GetServerSideProps = serverSidePropsHandler(
await Promise.all([
ssg.fetchQuery("site", { site: domainOrSubdomain }),
ssg.fetchQuery("site.page", { site: domainOrSubdomain, page: pageSlug }),
ssg.fetchQuery("site.page", {
site: domainOrSubdomain,
page: pageSlug,
renderContent: true,
}),
])
return {
@ -55,13 +59,11 @@ function SitePagePage({
const site = siteResult.data
const subscription = subscriptionResult.data
const page = pageResult.data
if (!site || !page) return null
const page = pageResult.data!
return (
<SiteLayout
site={site}
site={site!}
title={page.title}
isLoggedIn={isLoggedIn}
subscription={subscription}

View File

@ -53,11 +53,9 @@ function SiteArchivesPage({
const subscription = subscriptionResult.data
const posts = postsResult.data?.nodes
if (!site || !posts) return null
return (
<SiteLayout
site={site}
site={site!}
title="Archives"
isLoggedIn={isLoggedIn}
subscription={subscription}