bgenc.net/scripts/new-post.js
Kaan Barmore-Genç 6c50ff1b84
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Add blog post about extensions and shadow dom
2024-05-18 23:51:44 -05:00

24 lines
666 B
JavaScript

import { format, formatISO } from 'date-fns';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const title = process.argv[2] ?? 'New Blog Post';
const slug = title.toLowerCase().replaceAll(' ', '-').slice(0, 60);
const filename = `${format(new Date(), 'yyyy.MM.dd')}.${slug}.md`;
const contents = `---
title: '${title}'
date: ${formatISO(new Date())}
description: 'Blog post description here'
---
`;
console.log('dirname', __dirname);
console.log('filename', filename);
fs.writeFileSync(path.join(__dirname, '..', 'src', 'routes', 'posts', filename), contents);