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
Added on

NPX Install

npx skill4agent add bulls-cows/skills yy-post-to-wx

SKILL.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

  1. Obtain WeChat Official Account API credentials:
  2. Save credentials to environment variables:
    • Project-level: Create
      .baoyu-skills/.env
      file
    • User-level: Create
      ~/.baoyu-skills/.env
      file
env
WECHAT_APP_ID=your_app_id
WECHAT_APP_SECRET=your_app_secret
  1. Create configuration file
    EXTEND.md
    (optional):
md
default_theme: default
default_color: blue
default_author: Your Name
need_open_comment: 1
only_fans_can_comment: 0

Configuration Item Description

Configuration ItemDescriptionDefault Value
default_theme
Default theme
default
default_color
Default colorTheme default
default_author
Default authorEmpty
need_open_comment
Whether to enable comments
1
only_fans_can_comment
Whether only fans can comment
0

Theme Options

  • default
    - Default theme, concise and elegant
  • grace
    - Elegant style, larger line height
  • simple
    - Minimalist style, removes borders and shadows
  • modern
    - Modern style, card-based design

Color Presets

blue
,
green
,
vermilion
,
yellow
,
purple
,
sky
,
rose
,
olive
,
black
,
gray
,
pink
,
red
,
orange
Custom hex color values are also supported, such as
#ff0000
.

Usage

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

ParameterDescriptionExample
<file>
Input file path
article.md
--theme <name>
Theme name
--theme grace
--color <color>
Color name or hex
--color green
--title <title>
Force specify title
--title "Article Title"
--summary <text>
Force specify summary
--summary "This is an article"
--author <name>
Force specify author
--author Zhang San
--cover <path>
Specify cover image
--cover ./cover.png
--no-cite
Disable external link to bottom citation conversion
--no-cite

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-cite

Workflow

  1. Load Configuration - Load configuration from EXTEND.md and .env
  2. Process Input - Read Markdown/HTML file, plain text is saved automatically
  3. Parse Metadata - Extract title, author, summary, cover from frontmatter
  4. Convert Format - Convert Markdown to WeChat-compatible HTML, apply theme styles
  5. Get Token - Obtain access_token via API
  6. Upload Images - Upload cover and body images, replace URLs
  7. Create Draft - Call API to create draft in Official Account
  8. 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.ts
Check items:
  • Bun runtime
  • Environment variable configuration
  • Whether API credentials exist

Dependencies

  • marked
    - Markdown parsing
  • front-matter
    - frontmatter parsing

Limitations

  • Does not support browser automation publishing (API-only)
  • Does not support multi-account management
  • Image size must comply with WeChat Official Account restrictions