managarten/memoro/apps/landing/update-mdx.mjs
Till-JS e7f5f942f3 chore: initial commit - consolidate 4 projects into monorepo
Projects included:
- maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing)
- manacore (Expo mobile + SvelteKit web + Astro landing)
- manadeck (NestJS backend + Expo mobile + SvelteKit web)
- memoro (Expo mobile + SvelteKit web + Astro landing)

This commit preserves the current state before monorepo restructuring.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 23:38:24 +01:00

49 lines
1.7 KiB
JavaScript

import { readFile, writeFile, readdir } from 'fs/promises';
import { join } from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const contentDir = join(__dirname, 'src', 'content');
async function updateMdxFiles() {
const collections = ['guides', 'blog', 'team'];
const languages = ['de', 'en'];
for (const collection of collections) {
for (const lang of languages) {
const collectionPath = join(contentDir, collection, lang);
try {
const files = await readdir(collectionPath);
for (const file of files) {
if (!file.endsWith('.mdx')) continue;
const filePath = join(collectionPath, file);
let content = await readFile(filePath, 'utf-8');
// Extrahiere die Frontmatter
const frontmatterMatch = content.match(/^---([\s\S]*?)---/);
if (!frontmatterMatch) continue;
const frontmatter = frontmatterMatch[1];
if (!frontmatter.includes('lang:') || !frontmatter.includes('slug:')) {
// Füge lang und slug hinzu, wenn sie fehlen
const slug = file.replace('.mdx', '');
const newFrontmatter = frontmatter.trim() + `\nlang: "${lang}"\nslug: "${slug}"\n`;
content = content.replace(frontmatterMatch[0], `---\n${newFrontmatter}---`);
await writeFile(filePath, content, 'utf-8');
console.log(`Updated ${filePath}`);
}
}
} catch (error) {
console.error(`Error processing ${collectionPath}:`, error);
}
}
}
}
updateMdxFiles().catch(console.error);