fix: hide page content by default when getting pages
This commit is contained in:
parent
2124753096
commit
cfc41fe2fd
|
|
@ -150,6 +150,8 @@ export async function getPagesBySite(
|
|||
visibility?: PageVisibilityEnum | null
|
||||
take?: number | null
|
||||
cursor?: string | null
|
||||
includeContent?: boolean
|
||||
includeExcerpt?: boolean
|
||||
},
|
||||
) {
|
||||
const site = await getSite(input.site)
|
||||
|
|
@ -204,7 +206,17 @@ export async function getPagesBySite(
|
|||
|
||||
const nodesRendered = await Promise.all(
|
||||
nodes.slice(0, take).map(async (node) => {
|
||||
if (!input.includeContent && !input.includeExcerpt) {
|
||||
return node
|
||||
}
|
||||
const rendered = await renderPageContent(node.content)
|
||||
if (!input.includeContent) {
|
||||
rendered.contentHTML = ""
|
||||
}
|
||||
if (!input.includeExcerpt) {
|
||||
rendered.excerpt = ""
|
||||
node.excerpt = ""
|
||||
}
|
||||
return {
|
||||
...node,
|
||||
autoExcerpt: rendered.excerpt,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,11 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
|||
|
||||
await Promise.all([
|
||||
ssg.fetchQuery("site", { site: domainOrSubdomain }),
|
||||
ssg.fetchQuery("site.pages", { site: domainOrSubdomain }),
|
||||
ssg.fetchQuery("site.pages", {
|
||||
site: domainOrSubdomain,
|
||||
take: 1000,
|
||||
includeExcerpt: true,
|
||||
}),
|
||||
ssg.fetchQuery("site.subscription", { site: domainOrSubdomain }),
|
||||
])
|
||||
|
||||
|
|
@ -41,7 +45,7 @@ function SiteIndexPage({
|
|||
}) {
|
||||
const { data: site } = trpc.useQuery(
|
||||
["site", { site: domainOrSubdomain }],
|
||||
{}
|
||||
{},
|
||||
)
|
||||
const { data: subscription } = trpc.useQuery([
|
||||
"site.subscription",
|
||||
|
|
@ -49,7 +53,7 @@ function SiteIndexPage({
|
|||
])
|
||||
const { data: posts } = trpc.useQuery([
|
||||
"site.pages",
|
||||
{ site: domainOrSubdomain },
|
||||
{ site: domainOrSubdomain, take: 1000, includeExcerpt: true },
|
||||
])
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -68,18 +68,20 @@ export const siteRouter = createRouter()
|
|||
.nullish(),
|
||||
take: z.number().optional(),
|
||||
cursor: z.string().optional(),
|
||||
includeContent: z.boolean().optional(),
|
||||
includeExcerpt: z.boolean().optional(),
|
||||
}),
|
||||
output: z.object({
|
||||
nodes: z.array(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
title: z.string(),
|
||||
content: z.string(),
|
||||
contentHTML: z.string().optional(),
|
||||
publishedAt: z.date().transform((v) => v.toISOString()),
|
||||
published: z.boolean(),
|
||||
slug: z.string(),
|
||||
excerpt: z.string().nullable(),
|
||||
autoExcerpt: z.string(),
|
||||
autoExcerpt: z.string().optional(),
|
||||
}),
|
||||
),
|
||||
total: z.number(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue