37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
const CONTENT_DIR = path.join(process.cwd(), 'content')
|
|
const KNIEPUNKT_DIR = path.join(CONTENT_DIR, 'kniepunkt')
|
|
const POSTS_DIR = path.join(CONTENT_DIR, 'posts')
|
|
|
|
function getFiles(dir) {
|
|
return fs.readdirSync(dir).map(f => path.join(dir, f)).filter(f => f.endsWith('.md'))
|
|
}
|
|
|
|
const allFiles = [...getFiles(KNIEPUNKT_DIR), ...getFiles(POSTS_DIR)]
|
|
|
|
allFiles.forEach(file => {
|
|
if (fs.existsSync(file)) {
|
|
let raw = fs.readFileSync(file, 'utf8')
|
|
let changed = false;
|
|
|
|
// Replace the specific block of quotes that causes issues
|
|
if (raw.includes('"\n"\n"')) {
|
|
raw = raw.replace(/"\n"\n"/g, ' ');
|
|
changed = true;
|
|
}
|
|
if (raw.includes('" \n" \n"')) {
|
|
raw = raw.replace(/" \n" \n"/g, ' ');
|
|
changed = true;
|
|
}
|
|
// Also fix the smashed text by looking for common lower-Upper boundaries that are NOT typical camel case
|
|
// Wait, the smashed text ONLY happened where ` "\n"\n"` or similar was removed completely!
|
|
|
|
if (changed) {
|
|
fs.writeFileSync(file, raw)
|
|
console.log(`Fixed quotes in ${path.basename(file)}`)
|
|
}
|
|
}
|
|
})
|