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,51 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import matter from 'gray-matter'
|
||||
|
||||
const CONTENT_DIR = path.join(process.cwd(), 'content', 'posts')
|
||||
const TITLES_FILE = path.join(process.cwd(), '..', '..', '..', '..', '..', '.gemini', 'antigravity', 'brain', '12f7ab79-1833-4303-aace-1f9957dc5f67', 'artikel_titles.md')
|
||||
|
||||
const rawTitles = fs.readFileSync(TITLES_FILE, 'utf8')
|
||||
const yamlBlockMatch = rawTitles.match(/```yaml\n([\s\S]*?)```/)
|
||||
if (!yamlBlockMatch) {
|
||||
console.error("Could not find yaml block")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const lines = yamlBlockMatch[1].split('\n')
|
||||
const titleMap = {}
|
||||
|
||||
lines.forEach(line => {
|
||||
// match filename: 'title'
|
||||
// using split to handle titles that contain colons
|
||||
const idx = line.indexOf(':')
|
||||
if (idx > -1) {
|
||||
const filename = line.slice(0, idx).trim()
|
||||
let title = line.slice(idx + 1).trim()
|
||||
|
||||
// strip quotes if present
|
||||
if (title.startsWith("'") && title.endsWith("'")) {
|
||||
title = title.slice(1, -1)
|
||||
} else if (title.startsWith('"') && title.endsWith('"')) {
|
||||
title = title.slice(1, -1)
|
||||
}
|
||||
|
||||
if (filename.endsWith('.md')) {
|
||||
titleMap[filename] = title
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const mdFiles = fs.readdirSync(CONTENT_DIR).filter(f => f.endsWith('.md'))
|
||||
|
||||
mdFiles.forEach(file => {
|
||||
if (titleMap[file]) {
|
||||
const p = path.join(CONTENT_DIR, file)
|
||||
let data = matter(fs.readFileSync(p, 'utf8'))
|
||||
|
||||
data.data.title = titleMap[file].replace(/''/g, "'") // restore escaped single quotes
|
||||
|
||||
fs.writeFileSync(p, matter.stringify(data.content, data.data))
|
||||
console.log(`Updated ${file} -> ${data.data.title}`)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user