Scaffold a new blog post with the correct folder structure and frontmatter
Create a new blog post with the correct folder structure based on the project conventions.
Arguments: $ARGUMENTS
draft: true on current branchbranch: Create a new git branch post/slug for the post (no draft flag)Ask the user the following questions one at a time:
my-awesome-post)src/blog/YYYY/slug/index.mdxsrc/blog/YYYY/slug.mdxBased on the answers, create the appropriate structure:
With images:
src/blog/YYYY/slug/
└── index.mdx
Without images:
src/blog/YYYY/slug.mdx
Use the current year for YYYY. Get it with: date +%Y
branch argument provided)Before creating files, create and switch to a new branch:
git checkout -b post/slug
Use today's date for the date field. Get it with: date +%Y-%m-%d
Default mode (with draft flag):
---
title: "Post Title"
date: YYYY-MM-DD
excerpt: ""
categories:
- Category
draft: true
---
Start writing here...
Branch mode (no draft flag):
---
title: "Post Title"
date: YYYY-MM-DD
excerpt: ""
categories:
- Category
---
Start writing here...
Once the file is created:
For default mode: 2. Remind them about the draft: true flag — remove it when ready to publish
For branch mode: 2. Tell them the branch name (post/slug) 3. Remind them to merge the branch to main when ready to publish
If they chose "with images":
index.mdxsrc="./image.png"width and height props on <Image> componentssips -g pixelWidth -g pixelHeight <image> to get dimensions