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

wechat-md-publisher

v0.1.1

Published

全功能微信公众号 Markdown 发布工具 - 支持草稿、发布、删除和多主题

Downloads

106

Readme

Wechat-MD-Publisher

全功能微信公众号 Markdown 发布工具 - 让内容创作更简单

License: Apache 2.0 TypeScript Node

✨ 简介

wechat-md-publisher 是一个强大的微信公众号 Markdown 发布工具,让你用最熟悉的 Markdown 格式创作,一键发布到微信公众号。

为什么选择它?

  • 🚀 完整功能 - 草稿管理、发布管理、多账号支持,一应俱全
  • 🎨 精美主题 - 8 个内置主题,支持本地和远程自定义主题
  • 🖼️ 智能处理 - 自动上传图片,MD5 缓存避免重复上传
  • 💻 双重接口 - CLI 命令行工具 + 完整编程 API
  • 高性能 - 多级缓存系统,Token、图片、主题全缓存
  • 📦 开箱即用 - 零配置启动,5 分钟上手

🎯 核心特性

完整的草稿管理

  • 创建草稿(支持本地图片、网络图片)
  • 列出草稿(分页查询)
  • 删除草稿(单个/批量)
  • 获取草稿总数

完整的发布管理

  • 发布草稿到微信公众号
  • 创建并发布(一步到位)
  • 列出已发布文章
  • 删除已发布文章
  • 查询发布状态

8 个精美内置主题

基于 @wenyan-md/core 提供的精美主题:

| 主题 | 风格 | 适用场景 | |------|------|----------| | default | 简洁经典 | 通用、正式文章 | | orangeheart | 温暖优雅 | 情感、生活类 | | rainbow | 活泼清爽 | 轻松、趣味内容 | | lapis | 清新极简 | 技术、专业内容 | | pie | 现代锐利 | 产品、设计类 | | maize | 柔和舒适 | 教育、知识分享 | | purple | 简约文艺 | 个人博客、文艺 | | phycat | 薄荷清新 | 科普、教程类 |

智能图片处理

  • 自动上传本地图片到微信素材库
  • 自动下载并上传网络图片
  • MD5 缓存机制,避免重复上传
  • 自动选择封面图
  • 支持微信图片 URL

多账号管理

  • 支持管理多个微信公众号
  • 快速切换默认账号
  • 账号信息安全存储

🚀 快速开始

1. 安装

# 克隆项目
git clone https://github.com/sipingme/wechat-md-publisher.git
cd wechat-md-publisher

# 安装依赖
pnpm install

# 构建项目
pnpm build

2. 配置账号

node dist/cli.js account add \
  --name "我的公众号" \
  --app-id wx_your_app_id \
  --app-secret your_app_secret \
  --default

💡 获取 AppID 和 AppSecret:登录微信公众平台 → 设置与开发 → 基本配置

3. 创建第一篇文章

创建 article.md

---
title: 我的第一篇文章
author: 作者名
cover: ./cover.jpg
---

# 欢迎使用 wechat-md-publisher

这是一个全功能的微信公众号 Markdown 发布工具。

## 主要特性

- 完整的草稿管理
- 完整的发布管理
- 8 个精美内置主题

![示例图片](./example.jpg)

4. 发布文章

# 方式一:创建草稿
node dist/cli.js draft create --file article.md --theme orangeheart

# 方式二:直接发布
node dist/cli.js publish create --file article.md --theme lapis

使用指南

CLI 命令

账号管理

# 添加账号
node dist/cli.js account add --name "公众号名" --app-id xxx --app-secret xxx --default

# 列出所有账号
node dist/cli.js account list

# 切换默认账号
node dist/cli.js account switch <account-id>

# 删除账号
node dist/cli.js account remove <account-id>

主题管理

# 列出所有主题
node dist/cli.js theme list

# 添加本地主题
node dist/cli.js theme add-local --name my-theme --path ./my-theme.css

# 添加远程主题 API
node dist/cli.js theme add-remote --name md2wechat --url https://api.md2wechat.cn --key xxx

# 删除主题
node dist/cli.js theme remove <theme-id>

草稿管理

# 创建草稿
node dist/cli.js draft create --file article.md --theme orangeheart

# 列出草稿
node dist/cli.js draft list --page 1 --size 20

# 删除草稿
node dist/cli.js draft delete <media-id>

# 查看草稿总数
node dist/cli.js draft count

发布管理

# 发布草稿
node dist/cli.js publish submit <media-id>

# 创建并发布(一步到位)
node dist/cli.js publish create --file article.md --theme lapis

# 列出已发布文章
node dist/cli.js publish list

# 删除已发布文章
node dist/cli.js publish delete <article-id>

# 查询发布状态
node dist/cli.js publish status <publish-id>

编程 API

import { container } from 'wechat-md-publisher';

// 初始化
await container.initialize();

// 添加账号
const accountService = container.getAccountService();
await accountService.addAccount({
    name: '我的公众号',
    appId: 'wx123',
    appSecret: 'secret',
    isDefault: true,
});

// 创建并发布
const publishService = await container.getPublishService();
const result = await publishService.createAndPublish({
    file: './article.md',
    theme: 'orangeheart',
});

console.log('发布成功:', result.publish_id);

自定义主题

创建 my-theme.css

:root {
    --primary-color: #ff6b6b;
    --text-color: #2c3e50;
}

#wenyan {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-color);
}

#wenyan h1 {
    font-size: 24px;
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}

#wenyan h2 {
    font-size: 20px;
    padding-left: 10px;
    border-left: 4px solid var(--primary-color);
}

添加主题:

node dist/cli.js theme add-local --name my-theme --path ./my-theme.css

使用主题:

node dist/cli.js draft create --file article.md --theme my-theme

🏗️ 项目架构

┌─────────────────────────────────────────┐
│           CLI Layer (CLI 层)            │
│  Commander.js + Ora + Chalk + Table    │
└─────────────────────────────────────────┘
                    ↓
┌─────────────────────────────────────────┐
│        Service Layer (服务层)           │
│  Account │ Theme │ Draft │ Publish     │
└─────────────────────────────────────────┘
                    ↓
┌─────────────────────────────────────────┐
│          Core Layer (核心层)            │
│  WechatClient │ ThemeEngine │ Renderer │
└─────────────────────────────────────────┘
                    ↓
┌─────────────────────────────────────────┐
│    Infrastructure (基础设施层)          │
│  Config │ Cache │ Logger │ HttpClient  │
└─────────────────────────────────────────┘

分层设计

  • CLI 层 - 用户交互界面
  • 服务层 - 业务逻辑编排
  • 核心层 - 核心功能实现
  • 基础设施层 - 基础功能支持

🛠️ 技术栈

  • 语言: TypeScript 5.0
  • 构建: Vite
  • CLI: Commander.js + Ora + Chalk + cli-table3
  • 配置: Conf + Zod
  • HTTP: Axios
  • 日志: Winston
  • 渲染: @wenyan-md/core
  • 测试: Vitest

⚙️ 配置说明

配置文件位置

  • macOS: ~/Library/Preferences/wechat-md-publisher-nodejs/config.json
  • Linux: ~/.config/wechat-md-publisher-nodejs/config.json
  • Windows: %APPDATA%\wechat-md-publisher-nodejs\Config\config.json

微信公众号配置

  1. 登录微信公众平台
  2. 进入「设置与开发」→「基本配置」
  3. 获取「开发者ID(AppID)」和「开发者密码(AppSecret)」
  4. 将服务器 IP 地址添加到「IP白名单」

📖 详细配置说明:https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Getting_Started_Guide.html

🎨 主题说明

内置主题来源

本项目的 8 个精美内置主题来自 @wenyan-md/core,这是一个优秀的微信公众号 Markdown 渲染引擎。

主题预览

使用不同主题查看效果:

# 测试所有主题
for theme in default orangeheart rainbow lapis pie maize purple phycat; do
    echo "Testing theme: $theme"
    node dist/cli.js draft create --file article.md --theme $theme
done

🐛 常见问题

1. Token 过期

Token 会自动刷新,如遇问题请重新配置账号。

2. 图片上传失败

  • 检查图片路径是否正确
  • 确保图片大小不为 0
  • 检查服务器 IP 是否在白名单中

3. 找不到主题

使用 node dist/cli.js theme list 查看可用主题。

4. 依赖安装失败

# 清理缓存
rm -rf node_modules pnpm-lock.yaml

# 重新安装
pnpm install

🙏 致谢

本项目的开发受到以下优秀项目的启发和支持:

  • @wenyan-md/core - 提供了强大的 Markdown 渲染引擎和 8 个精美的内置主题,是本项目的核心依赖
  • wenyan-cli - 提供了优秀的 CLI 设计思路和用户体验参考

📞 联系方式

  • 作者: [email protected]
  • GitHub: https://github.com/sipingme/wechat-md-publisher
  • Issues: https://github.com/sipingme/wechat-md-publisher/issues

📄 开源协议

Apache License 2.0

Copyright (c) 2026 [email protected]

🌟 Star History

如果这个项目对你有帮助,欢迎 Star ⭐️


让 Markdown 写作更简单,让内容发布更高效! 🚀