ci: migrate GitHub actions to Gitea actions
Deploy CV Site (andreknie.de) / deploy (push) Canceled after 0s
Deploy CV Site (andreknie.de) / deploy (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import matter from 'gray-matter'
|
||||
|
||||
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)) {
|
||||
const raw = fs.readFileSync(file, 'utf8')
|
||||
// Fast check for floating quotes
|
||||
if (raw.includes(' " \n" \n"') || raw.includes(' "\n"\n"')) {
|
||||
const data = matter(raw)
|
||||
|
||||
let newContent = data.content.replace(/ "\n"\n"/g, '').replace(/ " \n" \n"/g, '').replace(/^"\n"\n/g, '').replace(/\n"\n/g, '\n').replace(/"\n/g, '\n')
|
||||
|
||||
if (newContent !== data.content) {
|
||||
data.content = newContent
|
||||
fs.writeFileSync(file, matter.stringify(data.content, data.data))
|
||||
console.log(`🧹 Cleaned up quotes in ${path.basename(file)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user