Files
e-tib.com/scripts/fix-media-urls.ts
Marc Mintel 26d325df44
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 38s
Build & Deploy / 🧪 QA (push) Successful in 1m22s
Build & Deploy / 🏗️ Build (push) Successful in 4m27s
Build & Deploy / 🚀 Deploy (push) Failing after 39s
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
fix(config): ensure analytics URL has protocol to prevent build crash
2026-05-12 13:01:18 +02:00

27 lines
821 B
TypeScript

import * as fs from 'fs';
import * as path from 'path';
function walk(dir: string, callback: (filePath: string) => void) {
const files = fs.readdirSync(dir);
for (const file of files) {
const filePath = path.join(dir, file);
if (fs.statSync(filePath).isDirectory()) {
walk(filePath, callback);
} else if (filePath.endsWith('.mdx') || filePath.endsWith('.md')) {
callback(filePath);
}
}
}
let replacedCount = 0;
walk(path.join(process.cwd(), 'content'), (filePath) => {
let content = fs.readFileSync(filePath, 'utf8');
if (content.includes('/api/media/file/')) {
content = content.replace(/\/api\/media\/file\//g, '/media/');
fs.writeFileSync(filePath, content, 'utf8');
replacedCount++;
}
});
console.log(`Successfully fixed media URLs in ${replacedCount} files.`);