SuperAPI AI Directory

wechat-publisher

Office & productivity

View repository

Updated 10-15 08:33

About this skill

wechat-publisher

One-click publish Markdown articles to WeChat Official Account drafts

Based on wenyan-cli OpenClaw skill.

Features

  • ✅ Automatically convert Markdown to WeChat Official Account format
  • ✅ Automatically upload images to WeChat image hosting
  • ✅ One-click push to drafts
  • ✅ Multiple theme support (code highlighting, Mac-style code blocks)
  • ✅ Supports local and network images

Quick Start

1. Install wenyan-cli

wenyan-cli needs to be installed globally:

npm install -g @wenyan-md/cli

Verify installation:

wenyan --help

Note: The publish.sh script will automatically detect and install wenyan-cli (if not installed)

2. Configure API credentials

API credentials are saved in /Users/leebot/.openclaw/workspace/TOOLS.md

Ensure the environment variables are set:

export WECHAT_APP_ID=your_wechat_app_id
export WECHAT_APP_SECRET=your_wechat_app_secret

Important: Ensure your IP has been added to the WeChat Official Account backend whitelist!

Configuration method:https://yuzhi.tech/docs/wenyan/upload

3. Prepare Markdown file

At the top of the filemustcontain complete frontmatter (required by wenyan):

---
title: 文章标题(必填!)
cover: https://example.com/cover.jpg  # 封面图(必填!)
---

# 正文开始

你的内容...

⚠️ Key finding (tested):

  • title and cover are both required fields!
  • Missing either one will cause an error: "Article cover not found"
  • Although the documentation says "cover can be omitted if the body has images", actual testing requires cover to be provided
  • All images (local/network) will be automatically uploaded to WeChat image hosting

Recommended cover image sources:

# 方案1: 相对路径(推荐,便于分享)
cover: ./assets/default-cover.jpg

# 方案2: 绝对路径
cover: /Users/bruce/photos/cover.jpg

# 方案3: 网络图片
cover: https://your-cdn.com/image.jpg

💡 Tip: When using relative paths, calculation starts from the directory where the Markdown file is located.

4. Publish article

Method 1: Use the publish.sh script

cd /Users/leebot/.openclaw/workspace/wechat-publisher
./scripts/publish.sh /path/to/article.md

Method 2: Use wenyan-cli directly

wenyan publish -f article.md -t lapis -h solarized-light

Method 3: Use in OpenClaw

"帮我发布这篇文章到微信公众号" + 附带 Markdown 文件路径

Theme options

wenyan-cli supports multiple themes:

Built-in themes:

Code highlighting themes:

  • atom-one-dark / atom-one-light
  • dracula
  • github-dark / github
  • monokai
  • solarized-dark / solarized-light (recommended)
  • xcode

Usage example:

# 使用 lapis 主题 + solarized-light 代码高亮
wenyan publish -f article.md -t lapis -h solarized-light

# 使用 phycat 主题 + GitHub 代码高亮
wenyan publish -f article.md -t phycat -h github

# 关闭 Mac 风格代码块
wenyan publish -f article.md -t lapis --no-mac-style

# 关闭链接转脚注
wenyan publish -f article.md -t lapis --no-footnote

Custom themes

Temporarily use a custom theme

wenyan publish -f article.md -c /path/to/custom-theme.css

Install a custom theme (permanent)

# 从本地文件安装
wenyan theme --add --name my-theme --path /path/to/theme.css

# 从网络安装
wenyan theme --add --name my-theme --path https://example.com/theme.css

# 使用已安装的主题
wenyan publish -f article.md -t my-theme

# 删除主题
wenyan theme --rm my-theme

List all themes

wenyan theme -l

Workflow

  1. Prepare content - Write in Markdown
  2. Run the script - One-click publish to drafts
  3. Review and publish - Review and publish in the Official Account backend

Markdown format requirements

Required Frontmatter

⚠️ Key (test results): wenyan-cli requires complete frontmatter!

---
title: 文章标题(必填!)
cover: 封面图片URL或路径(必填!)
---

Example 1: Relative path (recommended)

---
title: 我的技术文章
cover: ./assets/cover.jpg
---

# 正文...

Example 2: Absolute path

---
title: 我的技术文章
cover: /Users/bruce/photos/cover.jpg
---

# 正文...

Example 3: Network image

---
title: 我的技术文章
cover: https://example.com/cover.jpg
---

# 正文...

❌ Incorrect example (will cause an error):

# 只有 title,没有 cover
---
title: 我的文章
---

错误信息:未能找到文章封面
# 完全没有 frontmatter
# 我的文章

错误信息:未能找到文章封面

💡 Important finding:

  • Although the official wenyan documentation says "cover can be omitted if the body has images"
  • butactual testing requires cover to be provided, otherwise it will cause an error
  • title and cover Both are indispensable

Image support

  • ✅ Local path:![](./images/photo.jpg)
  • ✅ Absolute path:![](/Users/bruce/photo.jpg)
  • ✅ Network image:![](https://example.com/photo.jpg)

All images will be automatically uploaded to the WeChat image hosting service!

Code blocks

```python
def hello():
    print("Hello, WeChat!")
```

Code highlighting and Mac-style decoration will be added automatically.

Troubleshooting

1. Upload failed: IP not in whitelist

Error message: ip not in whitelist

Solution:

  1. Get your public IP:curl ifconfig.me
  2. Log in to the WeChat Official Account backend:https://mp.weixin.qq.com/
  3. Development → Basic Configuration → IP Whitelist → Add your IP

2. wenyan-cli not installed

Error message: wenyan: command not found

Solution:

npm install -g @wenyan-md/cli

3. Environment variable not set

Error message: WECHAT_APP_ID is required

Solution:

export WECHAT_APP_ID=your_wechat_app_id
export WECHAT_APP_SECRET=your_wechat_app_secret

Or in ~/.zshrc / ~/.bashrc permanently add.

4. Missing Frontmatter

Error message: title is required in frontmatter

Solution: Add at the top of the Markdown file:

---
title: 你的文章标题
---

References

Changelog

2026-02-05 - v1.0.0

  • ✅ Initial version
  • ✅ Wrapped based on wenyan-cli
  • ✅ Supports one-click publishing to drafts
  • ✅ Multi-theme support
  • ✅ Automatic image upload

License

Apache License 2.0 (inherited from wenyan-cli)