Make `autoExcerpt` nullable
This commit is contained in:
parent
b8f5e6d934
commit
23f92dabc9
|
|
@ -1,9 +0,0 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `autoExcerpt` to the `pages` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "pages" ADD COLUMN "autoExcerpt" TEXT NOT NULL,
|
||||
ALTER COLUMN "excerpt" DROP NOT NULL;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "pages" ADD COLUMN "autoExcerpt" TEXT,
|
||||
ALTER COLUMN "excerpt" DROP NOT NULL;
|
||||
|
|
@ -112,7 +112,7 @@ model Page {
|
|||
title String
|
||||
content String
|
||||
excerpt String?
|
||||
autoExcerpt String
|
||||
autoExcerpt String?
|
||||
format String @default("markdown")
|
||||
slug String
|
||||
site Site @relation(name: "SitePages", fields: [siteId], references: [id], onDelete: Cascade)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export const SiteHome: React.FC<{
|
|||
return (
|
||||
<div className="space-y-14">
|
||||
{posts.nodes.map((post) => {
|
||||
const excerpt = post.excerpt || post.autoExcerpt
|
||||
return (
|
||||
<div key={post.id} className="block">
|
||||
<h3 className="text-2xl font-medium">
|
||||
|
|
@ -20,8 +21,8 @@ export const SiteHome: React.FC<{
|
|||
{formatDate(post.publishedAt)}
|
||||
</div>
|
||||
<div className="mt-3 text-zinc-500">
|
||||
{post.excerpt || post.autoExcerpt}
|
||||
{"..."}
|
||||
{excerpt}
|
||||
{excerpt && "..."}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export type PostOnSiteHome = {
|
|||
id: string
|
||||
title: string
|
||||
excerpt?: string | null
|
||||
autoExcerpt: string
|
||||
autoExcerpt?: string | null
|
||||
slug: string
|
||||
publishedAt: string | Date
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export const siteRouter = createRouter()
|
|||
published: z.boolean(),
|
||||
slug: z.string(),
|
||||
excerpt: z.string().nullable(),
|
||||
autoExcerpt: z.string(),
|
||||
autoExcerpt: z.string().nullable(),
|
||||
})
|
||||
),
|
||||
total: z.number(),
|
||||
|
|
@ -102,7 +102,7 @@ export const siteRouter = createRouter()
|
|||
title: z.string(),
|
||||
content: z.string(),
|
||||
excerpt: z.string().nullable(),
|
||||
autoExcerpt: z.string(),
|
||||
autoExcerpt: z.string().nullable(),
|
||||
published: z.boolean(),
|
||||
publishedAt: z.date().transform((v) => v.toISOString()),
|
||||
slug: z.string(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue