Skip to content

shane-new-post Guide

Once shane-new-post is installed (see Install & Quick Start), it drops a scripts/new-post.js into the project. There are two ways to run it. If pnpm new-post says the script doesn’t exist, see Verify the install — the short version is that some package managers skip the setup step, and Installation Internals explains exactly why and how to finish it by hand.

Run it with no arguments:

Terminal window
npm run new-post

You’ll be walked through, in order:

Title

Required Asked first, and asked again if left blank.

Filename

Required A slug is suggested from the title — press enter to accept it, or type a different one.

Tags

Optional Comma-separated; previously used tags across existing posts are listed for reference before you’re asked.

Description / featured / draft / mdx

Optional Leave blank for the default (empty description, not featured, not a draft, .md instead of .mdx).

The filename is checked for path separators, illegal characters, and .. traversal — an invalid entry re-prompts instead of crashing.

The filename is the only required positional argument, and it must come first. Everything after it is a key:value pair, and — unlike the filename — those pairs can be written in any order, separated by / (or split across lines with a trailing \):

Terminal window
pnpm new-post "getting-started" title:Getting Started/description:An intro post/tags:[astro,web]/draft:F/featured:T/mdx:T

This is exactly equivalent — same keys, different order, split with \ instead of packed onto one line:

Terminal window
pnpm new-post "getting-started" \
mdx:T \
featured:T \
title:Getting Started \
tags:[astro,web] \
draft:F \
description:An intro post
Key Alias Required Description
title — Yes Post title. Command mode exits with an error if it’s missing.
description desc No Post description. Empty string if omitted.
tags tag No Comma-separated inside brackets: [tag1,tag2]. Empty list if omitted.
draft — No Boolean, see below. Defaults to false.
featured — No Boolean, see below. Defaults to false.
mdx — No Boolean, see below. T/true creates a .mdx file; otherwise .md.

Boolean values (draft, featured, mdx) are case-insensitive and accept the shorthand T / F alongside the full words true / false. Only t or true in any casing counts as yes — f, false, an empty value, or leaving the key out entirely all mean no. There’s no dedicated “false” check; anything that isn’t a t/true match simply falls through to the default.

Unrecognized keys (a typo, or a leftover key from shane-new-doc’s vocabulary like order) are printed as a warning and skipped — they don’t stop the post from being created.

  • Directorysrc/
    • Directorycontent/
      • Directoryposts/
        • getting-started.md new post
  • Directorypublic/
    • Directoryimg/
      • Directorygetting-started/ matching image folder, empty
        • …
  • Refuses to overwrite an existing post with the same filename — errors out instead of touching it.
  • Automatically creates a matching image folder (named after the post’s filename, without extension) for every new post.
  • Supports both .md and .mdx; if the filename already ends in one of those, it’s used as-is and the mdx flag is ignored for the extension.
  • Frontmatter string values (title, description, tags, author) are always quote-escaped, so a value containing a colon, #, or quote mark won’t break the parser.