An Astro-based blog.
- Node.js
- Install deps:
npm install - Start dev server:
npm run dev - Build site:
npm run build - Preview build:
npm run preview
- Drafts:
src/content/drafts/*.md - Published posts:
src/content/blog/*.md
src/content.config.ts defines the blog frontmatter schema. Posts in src/content/blog must satisfy that schema.
This repo provides a command that generates a Markdown file with a complete frontmatter template under src/content/drafts:
- Command:
npm run new
Run:
npm run new
You will be prompted for:
TitleDescription(can be empty)Slug(defaults to a slugified title)Tags(comma-separated, optional)Hero image path(optional)
Note: when passing args through npm run, include --.
npm run new -- --title "My Post" --description "..." --slug "my-post"npm run new -- --tags "astro,typescript"npm run new -- --heroImage "../assets/hero.png"npm run new -- --date "2025-12-29"npm run new -- --updated "2025-12-29"
Show help:
npm run new -- --help
The generated frontmatter matches src/content.config.ts:
- Required
title: stringdescription: stringpubDate:YYYY-MM-DD
- Optional
updatedDate:YYYY-MM-DD(optional; if omitted, the blog post page will automatically use the source file's last modified time when it's later thanpubDate)tags: array of strings (generated; empty array if omitted)heroImage: optional image reference (generated as a commented placeholder if omitted)
When you are ready to publish:
- Publish drafts with the script:
- Publish all drafts:
npm run post - Publish drafts whose filename/path contains a substring:
npm run post <name> - Publish one draft by slug (fuzzy match):
npm run post -- --slug "my-post" - Publish one draft by explicit path:
npm run post -- --file "src/content/drafts/my-post.md"
- Publish all drafts:
- Run
npm run dev(ornpm run build) to verify it parses and renders