npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shuent/markdown-generator

v0.2.5

Published

Modern TypeScript CLI for generating markdown files with templates and interactive prompts

Readme

markdown-generator

A modern, TypeScript-based CLI tool for generating markdown files with templates, interactive prompts, and variable interpolation. Perfect for blogs, documentation, and note-taking workflows.

Why markdown-generator? The Pain We Solve

You have a brilliant idea for a blog post. You open your editor, ready to write. But first, you must perform the ritual:

  1. Create the file: You manually type out 2024-05-21-my-brilliant-idea.md in the correct directory, hoping you didn't make a typo in the date.
  2. Find a template: You hunt for a previous post to copy-paste the frontmatter.
  3. Clean up: You painstakingly update the title, change the date to today, and clear out the old tags.

This isn't just a minor inconvenience; it's a creative bottleneck. This repetitive, manual setup drains your momentum before you've even written a single word. In a team, it leads to inconsistent file names and messy frontmatter.

markdown-generator automates this entire tedious process. It bridges the gap between idea and execution, letting you focus on what truly matters: your content.

Use Cases: Where mdg Shines

  • For the Blogger & Content Creator:

    • Before: "Ugh, I need to figure out the filename slug and copy the frontmatter from last week's post."
    • After: Run mdg --var slug="my-article" title="My Article" tags="tech,tutorial", and start writing immediately. The file is created with all your metadata pre-filled. Your creative flow is never interrupted.
  • For the Documentation Team:

    • Before: New team members create files with inconsistent naming conventions (YYYY-MM-DD vs DD-MM-YYYY) and forget required frontmatter fields.
    • After: The mdg.config.ts acts as an enforceable style guide. Everyone on the team uses mdg to generate consistent, error-free documentation files, every single time.
  • For the Diligent Note-Taker:

    • Before: A fleeting idea strikes during a meeting. You scramble to create a new file, name it, and add context, but the idea's initial spark is lost in the process.
    • After: Simply type mdg --template note --var slug="meeting-notes" title="Weekly Planning". A structured note file appears, ready for you to capture your thoughts without breaking stride.

Our goal is simple: to eliminate the boring, repetitive tasks and let you stay in your creative zone. Let mdg handle the housekeeping, so you can focus on writing.

Features

  • 🚀 Interactive Mode: No arguments needed - just run mdg and follow the prompts
  • 📝 Multiple Templates: Define and use different templates for various content types
  • 🔤 Variable Interpolation: Use variables like {{title}}, {{author}}, {{date}} in templates
  • 🎯 Smart Filename Generation: Auto-generate filenames with date prefixes and your chosen slug
  • 💡 TypeScript: Fully typed for better development experience
  • Fast: Built with modern tooling for optimal performance

Installation

npm install -g @shuent/markdown-generator
# or
npm install --save-dev @shuent/markdown-generator

Usage

Interactive Mode (Recommended)

Simply run mdg without arguments:

$ mdg
? Select a template: (Use arrow keys)
❯ blog
  note
  documentation
? Slug: my-awesome-post
? Title: My Awesome Post
? Tags: typescript, cli
? Author: John Doe
✓ Created: blog/2024-01-15-my-awesome-post.md

Direct Mode

Specify variables using the --var flag:

# Create a blog post with slug
mdg --var slug="my-blog-post"

# Create with specific template and slug
mdg --template blog --var slug="my-blog-post"
# or use the short form
mdg -t blog --var slug="my-blog-post"

# Create with multiple variables
mdg --var slug="my-blog-post" title="My Blog Post" author="John Doe" tags="typescript,cli"

# Any variable can be passed
mdg --var slug="my-post" category="tutorial" draft="true"

# List available templates
mdg list

Quick Mode

For default template:

mdg --var slug="first-article"
# Creates: blog/2024-01-15-first-article.md (using default template)
# You can then edit the title in the generated markdown file

Quick Start

  1. Initialize your project:

    mdg init

    This command will:

    • Create a mdg.config.js configuration file
    • Set up a mdg_templates/ directory with sample templates
    • Guide you through initial configuration
  2. Start generating:

    mdg  # Interactive mode
  3. Customize your setup:

    • Edit mdg.config.js to add/modify templates
    • Customize template files in the mdg_templates/ directory
    • Add your own variables and prompts

Configuration

Create mdg.config.js or mdg.config.ts in your project root. See the sample/ directory for examples:

// mdg.config.ts
import { MdgConfig } from 'markdown-generator';

const config: MdgConfig = {
  // Default template (when no template specified)
  defaultTemplate: 'blog',

  // Global variables available to all templates
  globalVariables: {
    // Common date variables
    date: () => new Date().toISOString().split('T')[0],
    datetime: () => new Date().toISOString(),
    timestamp: () => Date.now().toString(),
    year: () => new Date().getFullYear().toString(),
    month: () => String(new Date().getMonth() + 1).padStart(2, '0'),
    day: () => String(new Date().getDate()).padStart(2, '0'),
    
    // Your custom variables
    author: 'John Doe',
    siteUrl: 'https://example.com',
  },

  // Template definitions
  templates: {
    blog: {
      fileName: '{{date}}-{{slug}}',
      directory: 'content/blog',
      template: './mdg_templates/blog.md',
      variables: {
        category: 'general',
      },
      prompts: {
        title: {
          type: 'input',
          message: 'Blog post title:',
        },
        slug: {
          type: 'input',
          message: 'Slug (URL-friendly name):',
        },
        tags: {
          type: 'input',
          message: 'Tags (comma-separated):',
        },
        category: {
          type: 'list',
          message: 'Category:',
          choices: ['general', 'tutorial', 'announcement'],
        },
      },
    },

    note: {
      fileName: '{{date}}-{{slug}}',
      directory: 'notes',
      template: './mdg_templates/note.md',
      prompts: {
        title: {
          type: 'input',
          message: 'Note title:',
        },
        type: {
          type: 'list',
          message: 'Note type:',
          choices: ['meeting', 'idea', 'todo'],
        },
      },
    },

    documentation: {
      fileName: '{{slug}}',
      directory: 'docs',
      template: './mdg_templates/doc.md',
      prompts: {
        title: {
          type: 'input',
          message: 'Documentation title:',
        },
        section: {
          type: 'input',
          message: 'Section:',
          default: 'guides',
        },
      },
    },
  },
};

export default config;

Template Files

Create template files with frontmatter and variable placeholders:

## <!-- mdg_templates/blog.md -->

title: "{{title}}"
date: {{date}}
tags: [{{tags}}]
author: {{author}}
category: {{category}}

---

# {{title}}

Write your content here...

Variables

All variables must be defined in your configuration. There are no built-in variables - this gives you complete control over your templates.

Common Variables

Here are some commonly used variables you can add to your config:

globalVariables: {
  // Date-related variables
  date: () => new Date().toISOString().split('T')[0], // YYYY-MM-DD
  datetime: () => new Date().toISOString(),
  timestamp: () => Date.now().toString(),
  year: () => new Date().getFullYear().toString(),
  month: () => String(new Date().getMonth() + 1).padStart(2, '0'),
  day: () => String(new Date().getDate()).padStart(2, '0'),
  
  // Static values
  author: 'John Doe',
  siteUrl: 'https://example.com',
}

Variable Types

  • Static values: author: 'John Doe'
  • Dynamic values: date: () => new Date().toISOString().split('T')[0]
  • From CLI: --var slug="my-post" title="My Title" customVar="value"
  • From prompts: Variables collected through interactive prompts

Prompt Types

Input Prompt

title: {
  type: 'input',
  message: 'What is the title?',
  default: 'Untitled',
}

List Prompt (Select One)

category: {
  type: 'list',
  message: 'Select a category:',
  choices: ['tech', 'life', 'work'],
}

Checkbox Prompt (Select Multiple)

features: {
  type: 'checkbox',
  message: 'Select features:',
  choices: ['images', 'code', 'diagrams'],
}

Advanced Usage

Custom Date Formats

templates: {
  daily: {
    fileName: '{{date:YYYY/MM/DD}}-daily',
    // Custom date format in filename
  }
}

Conditional Variables

variables: {
  isDraft: () => process.env.NODE_ENV !== 'production',
  environment: () => process.env.NODE_ENV || 'development',
}

Nested Directories

templates: {
  projectDocs: {
    directory: 'projects/{{project}}/docs',
    prompts: {
      project: {
        type: 'input',
        message: 'Project name:',
      },
    },
  },
}

CLI Commands

# Initialize configuration and templates
mdg init

# Show help
mdg --help

# Show version
mdg --version

# List available templates
mdg list

# Create with specific template
mdg --template [template-name] --var slug="[slug]"
# or use the short form
mdg -t [template-name] --var slug="[slug]"

# Create with any variables
mdg --var slug="[slug]" title="[title]" author="[author]" tags="[tags]"

# Interactive mode (when no variables provided)
mdg

Development

# Clone the repository
git clone https://github.com/yourusername/markdown-generator

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Development mode
npm run dev

License

MIT