@md2wp/cli
v1.0.1
Published
CLI tool for publishing markdown to WordPress
Readme
@md2wp/cli
CLI tool for publishing markdown files to WordPress with Gutenberg blocks
Features
- 📝 Publish markdown files directly to WordPress
- 🎨 Converts markdown to Gutenberg blocks (not plain HTML!)
- 🖼️ Automatic image upload and URL replacement
- 🔄 Intelligent image caching (avoid duplicate uploads)
- ✅ Validate markdown and frontmatter before publishing
- 📋 View current configuration
- 🔐 Secure authentication using WordPress Application Passwords
Installation
npm install -g @md2wp/cliQuick Start
# Initialize configuration
md2wp init
# Validate a markdown file
md2wp validate my-post.md
# Publish to WordPress
md2wp publish my-post.md
# View configuration
md2wp configCommands
md2wp init
Create .md2wprc.json and .env configuration files.
md2wp validate <file>
Validate markdown file before publishing.
Options:
--verbose- Show detailed validation output
md2wp publish <file>
Publish a markdown file to WordPress.
Options:
--draft- Publish as draft (override frontmatter)--dry-run- Preview without making API calls
md2wp config
Show current configuration.
Options:
--verbose- Show full configuration JSON
Configuration
Create a .md2wprc.json file:
{
"wordpress": {
"siteUrl": "https://yoursite.com",
"username": "your-username"
},
"posts": {
"defaultStatus": "draft",
"defaultAuthor": 1
},
"images": {
"basePath": "./images",
"uploadPath": "/wp-content/uploads/md2wp/"
}
}Create a .env file:
MD2WP_PASSWORD=your-application-passwordFrontmatter
Add frontmatter to your markdown files:
---
title: 'My Post Title'
status: draft
slug: my-post-slug
tags:
- tutorial
- markdown
categories:
- development
excerpt: 'A short description'
date: 2024-01-15
---
# Your Content Here
Documentation
For full documentation, visit https://github.com/TeamNickHart/md2wp
License
MIT © Nicholas Hart
