feat: migration von directus zu payloadcms
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 1m19s
Build & Deploy / 🧪 QA (push) Failing after 3m32s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🏗️ Build (push) Failing after 7m51s
Build & Deploy / ⚡ Lighthouse (push) Has been skipped
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / ♿ WCAG (push) Has been skipped
Build & Deploy / 🛡️ Quality Gates (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 10s

This commit is contained in:
2026-02-24 19:25:43 +01:00
parent 2bac8d6e8a
commit f7aa880d9f
91 changed files with 1010 additions and 1028 deletions

View File

@@ -56,10 +56,8 @@ function ensureChildren(parsedNodes: any[]): any[] {
function parseInlineMarkdown(text: string): any[] {
// Simple regex-based inline parser for bold and italic
// Matches **bold**, __bold__, *italic*, _italic_
const regex = /(\*\*|__|TextNode)(.*?)\1|(\*|_)(.*?)\3/g;
const nodes: any[] = [];
let lastIndex = 0;
let match;
const createTextNode = (content: string, format = 0) => ({
detail: 0,
@@ -231,10 +229,12 @@ export function parseMarkdownToLexical(markdown: string): any[] {
return text
.replace(/<section[^>]*>/g, '')
.replace(/<\/section>/g, '')
.replace(/<h3[^>]*>(.*?)<\/h3>/g, '### $1\n\n')
.replace(/<p[^>]*>(.*?)<\/p>/g, '$1\n\n')
.replace(/<strong[^>]*>(.*?)<\/strong>/g, '**$1**')
.replace(/<h[1-6][^>]*>([\s\S]*?)<\/h[1-6]>/g, '### $1\n\n')
.replace(/<p[^>]*>([\s\S]*?)<\/p>/g, '$1\n\n')
.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/g, '**$1**')
.replace(/<em[^>]*>([\s\S]*?)<\/em>/g, '_$1_')
.replace(/&nbsp;/g, ' ')
.replace(/^(#{1,6}\s+.*)$/gm, '\n\n$1\n\n') // MAKE HEADINGS THEIR OWN CHUNK
.trim();
}
@@ -330,6 +330,11 @@ export function parseMarkdownToLexical(markdown: string): any[] {
continue;
}
// Skip horizontal rules (---)
if (/^-{3,}$/.test(chunk)) {
continue;
}
const headingMatch = chunk.match(/^(#{1,6})\s+(.*)/);
if (headingMatch) {
const level = Math.min(headingMatch[1].length + 1, 6);
@@ -342,6 +347,18 @@ export function parseMarkdownToLexical(markdown: string): any[] {
direction: 'ltr',
children: parseInlineMarkdown(headingMatch[2]),
});
// If there's more text after the heading line in this chunk, emit as paragraph(s)
const rest = chunk.slice(chunk.indexOf('\n') + 1).trim();
if (rest && chunk.includes('\n')) {
// Split remaining lines by single newlines for multi-paragraph support
const subParagraphs = rest.split(/\n\s*\n/);
for (const sub of subParagraphs) {
const trimmed = sub.trim();
if (trimmed && !/^-{3,}$/.test(trimmed)) {
nodes.push(paragraphNode(trimmed));
}
}
}
continue;
}