generate-blog-metadata.mjs

_scripts/generate-blog-metadata.mjs
#!/usr/bin/env node
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const ROOT_DIR = path.resolve(__dirname, '..')
const POSTS_DIR = path.join(ROOT_DIR, 'src/app/(post)/post')
const OUTPUT_FILE = path.join(ROOT_DIR, '_data/_blog.json')
function extractMetadata(filePath) {
try {
const content = fs.readFileSync(filePath, 'utf8')
// Match `const metadata: PageMetadata = { … }` (folder-per-post shape)
const metadataMatch = content.match(
/^const metadata[^=]*=\s*({[\s\S]*?^})/m

Showing the first 20 lines.

Get full code

Support

Talk to the developers of this project to learn more

We have been building professional websites for big clients for over 15 years. Gallop templates and blocks is our best foundation for SEO websites and web apps.

© 2026 Web Plant Media, LLC