From 2e854c3af2c0099b9393df9dcaa5193b897bf57a Mon Sep 17 00:00:00 2001 From: John Riccardi Date: Wed, 8 Apr 2026 14:32:37 -0500 Subject: [PATCH 1/2] Add new-post script to scaffold draft posts with frontmatter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds `pnpm new-post "Post Title"` — slugifies the title, fills in today's date, and creates a prefixed draft file in src/content/blog/. Co-Authored-By: Claude Sonnet 4.6 --- package.json | 3 ++- scripts/new-post.js | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 scripts/new-post.js diff --git a/package.json b/package.json index 4e3d815..dc37d03 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "build": "astro build", "preview": "astro preview", "astro": "astro", - "prettier:write": "prettier . --write" + "prettier:write": "prettier . --write", + "new-post": "node scripts/new-post.js" }, "dependencies": { "@astrojs/check": "^0.9.8", diff --git a/scripts/new-post.js b/scripts/new-post.js new file mode 100644 index 0000000..ca6ad8a --- /dev/null +++ b/scripts/new-post.js @@ -0,0 +1,48 @@ +#!/usr/bin/env node + +import { writeFileSync, existsSync } from 'fs' +import { join, dirname } from 'path' +import { fileURLToPath } from 'url' + +const __dirname = dirname(fileURLToPath(import.meta.url)) + +const title = process.argv.slice(2).join(' ') + +if (!title) { + console.error('Usage: pnpm new-post "My Post Title"') + process.exit(1) +} + +const slug = title + .toLowerCase() + .replace(/[^a-z0-9\s-]/g, '') + .trim() + .replace(/\s+/g, '-') + +const today = new Date().toISOString().split('T')[0] + +const frontmatter = `--- +title: '${title}' +description: '' +pubDate: '${today}' +# updatedDate: '${today}' +# heroImage: '../../assets/images/your-image.jpg' +--- +` + +const outputPath = join( + __dirname, + '..', + 'src', + 'content', + 'blog', + `.${slug}.mdx` +) + +if (existsSync(outputPath)) { + console.error(`File already exists: ${outputPath}`) + process.exit(1) +} + +writeFileSync(outputPath, frontmatter) +console.log(`Created draft: src/content/blog/.${slug}.mdx`) From 85c6a4409ab1df5de71c78cfef82718044470efa Mon Sep 17 00:00:00 2001 From: John Riccardi Date: Wed, 8 Apr 2026 14:53:10 -0500 Subject: [PATCH 2/2] Document pnpm new-post script in README Co-Authored-By: Claude Sonnet 4.6 --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 874b16f..336c04f 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,13 @@ heroImage: '../../assets/images/hero.jpg' # Optional - relative path from conten Files prefixed with `.` (e.g., `.draft-post.md`) are excluded from builds. +**Shortcut**: Use `pnpm new-post` to scaffold a draft with pre-filled frontmatter: + +```bash +pnpm new-post "My Post Title" +# Creates: src/content/blog/.my-post-title.mdx +``` + ## Claude Code Configuration This project includes a `.claude.json` file that configures the Playwright MCP server for automated browser testing when using [Claude Code](https://claude.ai/code). See `CLAUDE.md` for detailed guidance on working with this codebase.