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,42 @@
|
||||
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)) {
|
||||
let raw = fs.readFileSync(file, 'utf8')
|
||||
let data = matter(raw)
|
||||
let content = data.content
|
||||
|
||||
// Clean up quotes
|
||||
let newContent = content
|
||||
.replace(/ "\n/g, '\n')
|
||||
.replace(/\n"\n/g, '\n')
|
||||
.replace(/\n"/g, '\n')
|
||||
.replace(/^"/g, '')
|
||||
.replace(/"$/g, '')
|
||||
.replace(/ "\r\n/g, '\r\n')
|
||||
.replace(/\r\n"\r\n/g, '\r\n')
|
||||
.replace(/\r\n"/g, '\r\n')
|
||||
.replace(/ +/g, ' ') // Optional: remove double spaces if any
|
||||
|
||||
// Some files have `KI-Quiz, Teil 1: einfache Fragen"` at the very top
|
||||
newContent = newContent.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