feat(cms): migrate from Directus to Payload v3 and remove contentlayer
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 3m43s
Build & Deploy / 🏗️ Build (push) Failing after 37s
Build & Deploy / 🧪 QA (push) Failing after 3m40s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s

This commit is contained in:
2026-02-22 20:50:51 +01:00
parent b2f5e2dd4d
commit 072b6b13f1
30 changed files with 4299 additions and 2062 deletions

30
apps/web/src/lib/posts.ts Normal file
View File

@@ -0,0 +1,30 @@
import { getPayload } from "payload";
import configPromise from "@payload-config";
export async function getAllPosts() {
if (!process.env.DATABASE_URI && !process.env.POSTGRES_URI) {
console.warn(
"⚠️ Bypassing Payload fetch during Next.js build: DATABASE_URI is missing.",
);
return [];
}
const payload = await getPayload({ config: configPromise });
const { docs } = await payload.find({
collection: "posts",
limit: 1000,
sort: "-date",
});
return docs.map((doc) => ({
title: doc.title as string,
description: doc.description as string,
date: doc.date as string,
tags: (doc.tags || []).map((t) =>
typeof t === "object" && t !== null ? t.tag : t,
) as string[],
slug: doc.slug as string,
thumbnail: doc.thumbnail as string,
body: { code: doc.content as string },
}));
}