yy-post-to-wx
Original:🇨🇳 Chinese
Translated
6 scripts
Directly publish local Markdown/HTML articles to WeChat Official Account draft box via WeChat Official Account API. Supports multiple themes, preset colors, and automatic image upload.
9installs
Sourcebulls-cows/skills
Added on
NPX Install
npx skill4agent add bulls-cows/skills yy-post-to-wxTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →Directly publish local Markdown/HTML articles to WeChat Official Account draft box via WeChat Official Account API. Supports multiple themes, preset colors, and automatic image upload.
Features
- ✅ Supports three input formats: Markdown, HTML, plain text
- ✅ Four theme styles: default, grace, simple, modern
- ✅ Twelve preset colors, supports custom colors
- ✅ Automatically upload local images to WeChat material library
- ✅ External links are converted to bottom citations by default
- ✅ Configuration file supports default author and comment settings
- ✅ Direct upload via API, no browser automation required
Configuration
First-time Configuration
-
Obtain WeChat Official Account API credentials:
- Visit https://mp.weixin.qq.com
- Go to Development → Basic Configuration
- Copy AppID and AppSecret
-
Save credentials to environment variables:
- Project-level: Create file
.baoyu-skills/.env - User-level: Create file
~/.baoyu-skills/.env
- Project-level: Create
env
WECHAT_APP_ID=your_app_id
WECHAT_APP_SECRET=your_app_secret- Create configuration file (optional):
EXTEND.md
md
default_theme: default
default_color: blue
default_author: Your Name
need_open_comment: 1
only_fans_can_comment: 0Configuration Item Description
| Configuration Item | Description | Default Value |
|---|---|---|
| Default theme | |
| Default color | Theme default |
| Default author | Empty |
| Whether to enable comments | |
| Whether only fans can comment | |
Theme Options
- - Default theme, concise and elegant
default - - Elegant style, larger line height
grace - - Minimalist style, removes borders and shadows
simple - - Modern style, card-based design
modern
Color Presets
bluegreenvermilionyellowpurpleskyroseoliveblackgraypinkredorangeCustom hex color values are also supported, such as .
#ff0000Usage
bash
# Using Bun
bun skills/yy-post-to-wx/scripts/main.ts <file> [options]
# Using npx bun
npx -y bun skills/yy-post-to-wx/scripts/main.ts <file> [options]Parameter Options
| Parameter | Description | Example |
|---|---|---|
| Input file path | |
| Theme name | |
| Color name or hex | |
| Force specify title | |
| Force specify summary | |
| Force specify author | |
| Specify cover image | |
| Disable external link to bottom citation conversion | |
Examples
bash
# Publish Markdown file
bun skills/yy-post-to-wx/scripts/main.ts ./my-article.md --theme default --color blue
# Specify author and cover
bun skills/yy-post-to-wx/scripts/main.ts ./post.md --author "Baoyu" --cover ./imgs/cover.png
# Disable citation conversion
bun skills/yy-post-to-wx/scripts/main.ts ./article.md --no-citeWorkflow
- Load Configuration - Load configuration from EXTEND.md and .env
- Process Input - Read Markdown/HTML file, plain text is saved automatically
- Parse Metadata - Extract title, author, summary, cover from frontmatter
- Convert Format - Convert Markdown to WeChat-compatible HTML, apply theme styles
- Get Token - Obtain access_token via API
- Upload Images - Upload cover and body images, replace URLs
- Create Draft - Call API to create draft in Official Account
- Output Result - Display media_id and management link
Prerequisites
- Node.js 18+ or Bun
- WeChat Official Account AppID and AppSecret
- Official Account has developer permissions enabled
- Server IP has been added to API whitelist
Dependency Installation
Using Bun (Recommended)
Bun will automatically install dependencies on first run:
bash
bun skills/yy-post-to-wx/scripts/main.ts <file>Using Node.js
Need to install dependencies manually:
bash
cd skills/yy-post-to-wx/scripts
npm install
cd ../../..Environment Check
It is recommended to run the environment check before first use:
bash
bun skills/yy-post-to-wx/scripts/check-permissions.tsCheck items:
- Bun runtime
- Environment variable configuration
- Whether API credentials exist
Dependencies
- - Markdown parsing
marked - - frontmatter parsing
front-matter
Limitations
- Does not support browser automation publishing (API-only)
- Does not support multi-account management
- Image size must comply with WeChat Official Account restrictions