feat: payload cms
This commit is contained in:
18
lib/blog.ts
18
lib/blog.ts
@@ -32,6 +32,8 @@ export interface PostFrontmatter {
|
||||
date: string;
|
||||
excerpt?: string;
|
||||
featuredImage?: string | null;
|
||||
focalX?: number;
|
||||
focalY?: number;
|
||||
category?: string;
|
||||
locale: string;
|
||||
public?: boolean;
|
||||
@@ -83,6 +85,14 @@ export async function getPostBySlug(slug: string, locale: string): Promise<PostM
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
|
||||
: null,
|
||||
focalX:
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
? doc.featuredImage.focalX
|
||||
: 50,
|
||||
focalY:
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
? doc.featuredImage.focalY
|
||||
: 50,
|
||||
public: doc._status === 'published',
|
||||
} as PostFrontmatter,
|
||||
content: doc.content as any, // Native Lexical Editor State
|
||||
@@ -117,6 +127,14 @@ export async function getAllPosts(locale: string): Promise<PostMdx[]> {
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
|
||||
: null,
|
||||
focalX:
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
? doc.featuredImage.focalX
|
||||
: 50,
|
||||
focalY:
|
||||
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
|
||||
? doc.featuredImage.focalY
|
||||
: 50,
|
||||
} as PostFrontmatter,
|
||||
// Pass the Lexical content object rather than raw markdown string
|
||||
content: doc.content as any,
|
||||
|
||||
Reference in New Issue
Block a user