Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 48 additions & 0 deletions scripts/new-post.js
Original file line number Diff line number Diff line change
@@ -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`)
Loading