chore: fix client side build error
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import {
|
||||
prefetchGetSite,
|
||||
prefetchGetSiteSubscriptions,
|
||||
} from "~/queries/site.server"
|
||||
import { prefetchGetPagesBySite } from "~/queries/page.server"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { dehydrate } from "@tanstack/react-query"
|
||||
import { queryClientServer } from "~/lib/query-client.server"
|
||||
import { fetchGetPage } from "~/queries/page.server"
|
||||
import { notFound } from "~/lib/server-side-props"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
const domainOrSubdomain = ctx.params!.site as string
|
||||
const pageSlug = ctx.params!.page as string
|
||||
const tag = ctx.params!.tag as string
|
||||
|
||||
await prefetchGetSite(domainOrSubdomain)
|
||||
await prefetchGetSiteSubscriptions({
|
||||
siteId: domainOrSubdomain,
|
||||
})
|
||||
|
||||
if (pageSlug) {
|
||||
const page = await fetchGetPage({
|
||||
site: domainOrSubdomain,
|
||||
page: pageSlug,
|
||||
render: true,
|
||||
includeAuthors: true,
|
||||
})
|
||||
|
||||
if (new Date(page!.date_published) > new Date()) {
|
||||
throw notFound()
|
||||
}
|
||||
} else {
|
||||
await prefetchGetPagesBySite({
|
||||
site: domainOrSubdomain,
|
||||
take: 1000,
|
||||
type: "post",
|
||||
visibility: PageVisibilityEnum.Published,
|
||||
render: true,
|
||||
...(tag && { tags: [tag] }),
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
dehydratedState: dehydrate(queryClientServer),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -6,60 +6,10 @@ import { SiteHeader } from "./SiteHeader"
|
||||
import { useRouter } from "next/router"
|
||||
import { useStore } from "~/lib/store"
|
||||
import { BlockchainInfo } from "~/components/common/BlockchainInfo"
|
||||
import { GetServerSideProps } from "next"
|
||||
import {
|
||||
prefetchGetSite,
|
||||
prefetchGetSiteSubscriptions,
|
||||
} from "~/queries/site.server"
|
||||
import { prefetchGetPagesBySite } from "~/queries/page.server"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { useGetSiteSubscriptions } from "~/queries/site"
|
||||
import { dehydrate } from "@tanstack/react-query"
|
||||
import { queryClientServer } from "~/lib/query-client.server"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
import { fetchGetPage } from "~/queries/page.server"
|
||||
import { notFound } from "~/lib/server-side-props"
|
||||
import { useGetPage } from "~/queries/page"
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
const domainOrSubdomain = ctx.params!.site as string
|
||||
const pageSlug = ctx.params!.page as string
|
||||
const tag = ctx.params!.tag as string
|
||||
|
||||
await prefetchGetSite(domainOrSubdomain)
|
||||
await prefetchGetSiteSubscriptions({
|
||||
siteId: domainOrSubdomain,
|
||||
})
|
||||
|
||||
if (pageSlug) {
|
||||
const page = await fetchGetPage({
|
||||
site: domainOrSubdomain,
|
||||
page: pageSlug,
|
||||
render: true,
|
||||
includeAuthors: true,
|
||||
})
|
||||
|
||||
if (new Date(page!.date_published) > new Date()) {
|
||||
throw notFound()
|
||||
}
|
||||
} else {
|
||||
await prefetchGetPagesBySite({
|
||||
site: domainOrSubdomain,
|
||||
take: 1000,
|
||||
type: "post",
|
||||
visibility: PageVisibilityEnum.Published,
|
||||
render: true,
|
||||
...(tag && { tags: [tag] }),
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
dehydratedState: dehydrate(queryClientServer),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export type SiteLayoutProps = {
|
||||
children: React.ReactNode
|
||||
title?: string | null
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import {
|
||||
SiteLayout,
|
||||
getServerSideProps as getLayoutServerSideProps,
|
||||
} from "~/components/site/SiteLayout"
|
||||
import { SiteLayout } from "~/components/site/SiteLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/site/SiteLayout.server"
|
||||
import { SitePage } from "~/components/site/SitePage"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { queryClientServer } from "~/lib/query-client.server"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import {
|
||||
SiteLayout,
|
||||
getServerSideProps as getLayoutServerSideProps,
|
||||
} from "~/components/site/SiteLayout"
|
||||
import { SiteLayout } from "~/components/site/SiteLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/site/SiteLayout.server"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { SiteArchives } from "~/components/site/SiteArchives"
|
||||
import { Profile, Notes } from "~/lib/types"
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { SiteHome } from "~/components/site/SiteHome"
|
||||
import { SiteLayout } from "~/components/site/SiteLayout"
|
||||
import { queryClientServer } from "~/lib/query-client.server"
|
||||
import { fetchGetSite } from "~/queries/site.server"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
import { dehydrate, QueryClient } from "@tanstack/react-query"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
import { fetchGetPagesBySite } from "~/queries/page.server"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import { SiteHome } from "~/components/site/SiteHome"
|
||||
import {
|
||||
SiteLayout,
|
||||
getServerSideProps as getLayoutServerSideProps,
|
||||
} from "~/components/site/SiteLayout"
|
||||
import { SiteLayout } from "~/components/site/SiteLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/site/SiteLayout.server"
|
||||
import { queryClientServer } from "~/lib/query-client.server"
|
||||
import { dehydrate } from "@tanstack/react-query"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { GetServerSideProps } from "next"
|
||||
import {
|
||||
SiteLayout,
|
||||
getServerSideProps as getLayoutServerSideProps,
|
||||
} from "~/components/site/SiteLayout"
|
||||
import { SiteLayout } from "~/components/site/SiteLayout"
|
||||
import { getServerSideProps as getLayoutServerSideProps } from "~/components/site/SiteLayout.server"
|
||||
import { serverSidePropsHandler } from "~/lib/server-side-props"
|
||||
import { SiteArchives } from "~/components/site/SiteArchives"
|
||||
import { Profile, Notes } from "~/lib/types"
|
||||
|
||||
Reference in New Issue
Block a user