feat: payload cms

This commit is contained in:
2026-02-26 01:32:22 +01:00
parent 1963a93123
commit 7d65237ee9
67 changed files with 3179 additions and 760 deletions

View File

@@ -35,7 +35,6 @@ export interface PostFrontmatter {
focalX?: number;
focalY?: number;
category?: string;
locale: string;
public?: boolean;
}
@@ -65,9 +64,9 @@ export async function getPostBySlug(slug: string, locale: string): Promise<PostM
collection: 'posts',
where: {
slug: { equals: slug },
locale: { equals: locale },
...(!isDev ? { _status: { equals: 'published' } } : {}),
},
locale: locale as any,
draft: isDev,
limit: 1,
});
@@ -83,7 +82,6 @@ export async function getPostBySlug(slug: string, locale: string): Promise<PostM
date: doc.date,
excerpt: doc.excerpt || '',
category: doc.category || '',
locale: doc.locale,
featuredImage:
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
@@ -113,11 +111,9 @@ export async function getAllPosts(locale: string): Promise<PostMdx[]> {
const { docs } = await payload.find({
collection: 'posts',
where: {
locale: {
equals: locale,
},
...(!isDev ? { _status: { equals: 'published' } } : {}),
},
locale: locale as any,
sort: '-date',
draft: isDev,
limit: 100,
@@ -125,7 +121,7 @@ export async function getAllPosts(locale: string): Promise<PostMdx[]> {
console.log(`[Payload] getAllPosts for ${locale}: Found ${docs.length} docs`);
return docs.map((doc) => {
const posts = docs.map((doc) => {
return {
slug: doc.slug,
frontmatter: {
@@ -133,7 +129,6 @@ export async function getAllPosts(locale: string): Promise<PostMdx[]> {
date: doc.date,
excerpt: doc.excerpt || '',
category: doc.category || '',
locale: doc.locale,
featuredImage:
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
@@ -151,6 +146,9 @@ export async function getAllPosts(locale: string): Promise<PostMdx[]> {
content: doc.content as any,
};
});
// Integrity check: only show posts with a featured image in listings/sitemap
return posts.filter((p) => !!p.frontmatter.featuredImage);
} catch (error) {
console.error(`[Payload] getAllPosts failed for ${locale}:`, error);
return [];