fix(web): remove redundant prop-types and unblock lint pipeline
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 10s
Build & Deploy / 🧪 QA (push) Failing after 2m24s
Build & Deploy / 🏗️ Build (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 3s

This commit is contained in:
2026-02-24 11:38:43 +01:00
parent 95a8b702fe
commit 6864903cff
205 changed files with 6570 additions and 1324 deletions

View File

@@ -2,6 +2,7 @@ import { getPayload } from "payload";
import configPromise from "../payload.config";
import fs from "fs";
import path from "path";
import { parseMarkdownToLexical } from "../src/payload/utils/lexicalParser";
function parseMatter(content: string) {
const match = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
@@ -39,29 +40,112 @@ async function run() {
const slug = file.replace(/\.mdx$/, "");
console.log(`Migrating ${slug}...`);
const existing = await payload.find({
collection: "posts",
where: { slug: { equals: slug } },
});
if (existing.docs.length === 0) {
await payload.create({
try {
const existing = await payload.find({
collection: "posts",
data: {
title: data.title || slug,
slug,
description: data.description || "",
date: data.date
? new Date(data.date).toISOString()
: new Date().toISOString(),
tags: (data.tags || []).map((t: string) => ({ tag: t })),
thumbnail: data.thumbnail || "",
content: body,
},
where: { slug: { equals: slug } },
});
console.log(`✔ Inserted ${slug}`);
} else {
console.log(`⚠ Skipped ${slug} (already exists)`);
const lexicalBlocks = parseMarkdownToLexical(body);
const lexicalAST = {
root: {
type: "root",
format: "",
indent: 0,
version: 1,
children: lexicalBlocks,
direction: "ltr",
},
};
// Handle thumbnail mapping
let featuredImageId = null;
if (data.thumbnail) {
try {
// Remove leading slash and find local file
const localPath = path.join(
process.cwd(),
"public",
data.thumbnail.replace(/^\//, ""),
);
const fileName = path.basename(localPath);
if (fs.existsSync(localPath)) {
// Check if media already exists in Payload
const existingMedia = await payload.find({
collection: "media",
where: { filename: { equals: fileName } },
});
if (existingMedia.docs.length > 0) {
featuredImageId = existingMedia.docs[0].id;
} else {
// Upload new media item
const fileData = fs.readFileSync(localPath);
const { size } = fs.statSync(localPath);
const newMedia = await payload.create({
collection: "media",
data: {
alt: data.title || fileName,
},
file: {
data: fileData,
name: fileName,
mimetype: fileName.endsWith(".png")
? "image/png"
: fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")
? "image/jpeg"
: "image/webp",
size,
},
});
featuredImageId = newMedia.id;
console.log(` ↑ Uploaded thumbnail: ${fileName}`);
}
}
} catch (e) {
console.warn(
` ⚠ Warning: Could not process thumbnail ${data.thumbnail}`,
);
}
}
if (existing.docs.length === 0) {
await payload.create({
collection: "posts",
data: {
title: data.title || slug,
slug,
description: data.description || "",
date: data.date
? new Date(data.date).toISOString()
: new Date().toISOString(),
tags: (data.tags || []).map((t: string) => ({ tag: t })),
content: lexicalAST as any,
featuredImage: featuredImageId,
},
});
console.log(`✔ Inserted ${slug}`);
} else {
await payload.update({
collection: "posts",
id: existing.docs[0].id,
data: {
content: lexicalAST as any,
featuredImage: featuredImageId,
},
});
console.log(`✔ Updated AST and thumbnail for ${slug}`);
}
} catch (err: any) {
console.error(`✘ FAILED ${slug}: ${err.message}`);
if (err.data?.errors) {
console.error(
` Validation errors:`,
JSON.stringify(err.data.errors, null, 2),
);
}
}
}