@next-md-blog/cli
v1.0.0
Published
CLI tool for initializing next-md-blog in your Next.js project
Downloads
7
Readme
@next-md-blog/cli
CLI tool for quickly initializing @next-md-blog/core in your Next.js project. Automatically sets up blog routes, installs dependencies, and configures everything you need to start blogging.
✨ Features
- 🚀 One-Command Setup - Initialize your blog in seconds
- 📦 Auto-Install - Automatically installs required packages
- 🎨 Auto-Configure - Sets up Tailwind CSS typography and dark mode
- 📝 Template Generation - Creates beautiful, modern blog templates
- 🌍 i18n Support - Optional multi-language setup
- 🖼️ OG Images - Optional Open Graph image generation
- ⚙️ Flexible - Interactive or non-interactive modes
📦 Installation
Use directly with npx (recommended):
npx @next-md-blog/cliOr install globally:
npm install -g @next-md-blog/cli
next-md-blog-init🚀 Quick Start
Run the CLI in your Next.js project root:
npx @next-md-blog/cliThe CLI will:
- ✅ Create a
posts/folder (or custom directory) - ✅ Add an example blog post (
welcome.md) - ✅ Create Next.js routes for
/blog/[slug]and/blogs - ✅ Set up OG image using Next.js file convention (
opengraph-image.tsx) - ✅ Create
next-md-blog.config.tswith SEO configuration - ✅ Automatically install
@next-md-blog/core - ✅ Automatically install
@tailwindcss/typography - ✅ Automatically install
@vercel/og(if OG images enabled) - ✅ Automatically update
globals.csswith typography plugin - ✅ Automatically add
@custom-variant darkfor dark mode support
📋 Options
Interactive Mode (Default)
The CLI will prompt you for configuration:
- Content directory name (default:
posts) - Blog route (default:
blog) - Blogs listing route (default:
blogs) - Create example post? (default: yes)
- Create blog pages? (default: yes)
- Create OG images? (default: yes)
- Enable i18n? (default: no)
- SEO settings (site name, URL, author, Twitter handle)
Non-Interactive Mode
Use flags for automated setup:
npx @next-md-blog/cli --non-interactive \
--content-dir=posts \
--blog-route=blog \
--blogs-route=blogs \
--example-post \
--blog-pages \
--og-image \
--site-name="My Blog" \
--site-url="https://example.com" \
--author="John Doe" \
--twitter="@johndoe"i18n Support
Enable multi-language support:
npx @next-md-blog/cli \
--i18n-enabled \
--locales=en,fr,es \
--locale-folder=[locale]This will:
- Create locale-based routes:
/[locale]/blog/[slug] - Organize posts by locale:
posts/en/,posts/fr/, etc. - Generate locale-aware pages
🎨 Generated Templates
The CLI generates modern, beautiful blog templates with:
- ✨ Modern Tailwind CSS styling
- 🎨 Neutral color palette
- 🌙 Black background in dark mode
- 📱 Fully responsive design
- ♿ Accessible semantic HTML
- 🎯 SEO-optimized structure
- 📊 Rich metadata display (date, author, reading time, word count, tags)
📁 Generated Structure
After running the CLI, your project will have:
your-project/
├── posts/
│ └── welcome.md
├── app/
│ ├── blog/
│ │ └── [slug]/
│ │ ├── page.tsx
│ │ └── opengraph-image.tsx (optional)
│ └── blogs/
│ └── page.tsx
├── next-md-blog.config.ts
└── app/globals.css (updated)⚙️ Configuration
The CLI creates next-md-blog.config.ts:
import { createConfig } from '@next-md-blog/core';
export default createConfig({
siteName: 'My Blog',
siteUrl: process.env.NEXT_PUBLIC_SITE_URL || 'https://example.com',
defaultAuthor: 'Your Name',
twitterHandle: '@yourhandle',
defaultLang: 'en',
});🎨 Styling Setup
The CLI automatically:
- Installs
@tailwindcss/typography - Adds to
globals.css:@import "tailwindcss"; @plugin "@tailwindcss/typography"; @custom-variant dark (&:is(.dark *));
📝 Command Line Options
| Option | Description | Default |
|--------|-------------|---------|
| --non-interactive, -y | Run without prompts | false |
| --content-dir | Posts directory name | posts |
| --blog-route | Blog post route | blog |
| --blogs-route | Blog listing route | blogs |
| --example-post | Create example post | true |
| --no-example-post | Skip example post | - |
| --blog-pages | Create blog pages | true |
| --no-blog-pages | Skip blog pages | - |
| --og-image | Create OG image | true |
| --no-og-image | Skip OG image | - |
| --i18n-enabled | Enable i18n | false |
| --locales | Comma-separated locales | en,fr |
| --locale-folder | Locale folder name | [locale] |
| --site-name | Site name | - |
| --site-url | Site URL | - |
| --author | Default author | - |
| --twitter | Twitter handle | - |
🔧 Requirements
- Next.js 13+ (App Router) or Next.js 12+ (Pages Router)
- Node.js 18+
- TypeScript (recommended)
📖 Documentation
For complete documentation and examples, visit the main repository.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📝 License
MIT
