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
27 lines
821 B
TypeScript
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.`);
|