58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
import fs from 'fs'
|
|
import path from 'path'
|
|
import matter from 'gray-matter'
|
|
|
|
const POSTS_DIR = path.join(process.cwd(), 'content', 'posts')
|
|
|
|
function getFiles(dir) {
|
|
return fs.readdirSync(dir).map(f => path.join(dir, f)).filter(f => f.endsWith('.md'))
|
|
}
|
|
|
|
const allPosts = getFiles(POSTS_DIR)
|
|
let items = []
|
|
|
|
allPosts.forEach((file) => {
|
|
const data = matter(fs.readFileSync(file, 'utf8'))
|
|
items.push({
|
|
file: path.basename(file),
|
|
title: data.data.title || 'Untitled',
|
|
date: data.data.date || 'Unknown',
|
|
source: data.data.source || 'unknown',
|
|
tags: data.data.tags ? data.data.tags.join(', ') : '',
|
|
})
|
|
})
|
|
|
|
// Sort by date descending
|
|
items.sort((a, b) => new Date(b.date) - new Date(a.date))
|
|
|
|
const articles = items.filter(i => i.source === 'linkedin-article')
|
|
const posts = items.filter(i => i.source === 'linkedin-post' || i.source === 'unknown')
|
|
|
|
let md = `# Post Inventory
|
|
|
|
Here are all the items currently in your \`Artikel\` subpage (\`content/posts/\`), clustered by Articles and Posts.
|
|
You can reply with the IDs you want me to delete (e.g., "Delete Post #4, Post #12, Article #2").
|
|
|
|
## 📄 Articles
|
|
|
|
| ID | Date | Title | Filename |
|
|
|---|---|---|---|
|
|
`
|
|
articles.forEach((a, i) => {
|
|
md += `| Article #${i+1} | ${a.date.substring?.(0,10) || a.date} | ${a.title} | \`${a.file}\` |\n`
|
|
})
|
|
|
|
md += `
|
|
|
|
## 💬 Posts (Shares / Stubs)
|
|
|
|
| ID | Date | Title | Filename |
|
|
|---|---|---|---|
|
|
`
|
|
posts.forEach((p, i) => {
|
|
md += `| Post #${i+1} | ${p.date.substring?.(0,10) || p.date} | ${p.title} | \`${p.file}\` |\n`
|
|
})
|
|
|
|
fs.writeFileSync('/home/andre/.gemini/antigravity/brain/12f7ab79-1833-4303-aace-1f9957dc5f67/post_inventory.md', md)
|
|
console.log('Artifact created.')
|