Loading...
Loading...
Fetch a Notion page by title, export to Markdown, convert Markdown to HTML with a user-provided CSS file, and create a Weixin draft via node-wxcli. Use when asked to publish Notion content into Weixin draftbox, or when moving Notion pages into Weixin draft as HTML.
npx skill4agent add inforix/skills notion-to-weixinauthor~/.agents/config.yamlnotion_to_weixin:
author: "Alice Wang"author: "Alice Wang"authorthumb_media_idthumb--format markdown--css-pathnotion_titleauthor--author~/.agents/config.yamlcss_path--format markdownassets/default.cssthumb_media_idnotion-clinotion auth setnode-wxclinode-wxcli auth setnode-wxcli auth logincurljqreferences/notion-search.json__TITLE__notion search --body @query.jsonnotion pages export <page_id> --assets=download -o <workdir>/page.md/tmp/notion-to-weixin/<slug-or-timestamp>author~/.agents/config.yamlauthor<workdir>/page.mdurlnode-wxcli material upload --type image --file <workdir>/assets/<image-file> --json | jq -r '.url'urlthumb_media_idnotion pages get <page_id> > <workdir>/page.jsoncover_type=$(jq -r '.cover.type // ""' <workdir>/page.json)
cover_url=$(jq -r '.cover | if .==null then "" elif .type=="external" then .external.url else .file.url end' <workdir>/page.json)fileexternalif [ "$cover_type" = "file" ]; then
jq -c '.cover' <workdir>/page.json | notion files read --body @- --output <workdir>/cover.jpg
else
curl -L "$cover_url" -o <workdir>/cover.jpg
fi
thumb_media_id=$(node-wxcli material upload --type thumb --file <workdir>/cover.jpg --json | jq -r '.media_id')image_count=$(node-wxcli material count --json | jq -r '.image_count')image_count > 0media_idoffset=$((image_count - 1))
thumb_media_id=$(node-wxcli material list --type image --offset "$offset" --count 1 --json | jq -r '.item[0].media_id')thumb_media_id--css-pathcss_pathcss_path=${css_path:-assets/default.css}node-wxcli draft add \
--title "<notion_title>" \
--author "<author>" \
--format markdown \
--content - \
--css-path <css_path> \
--need-open-comment=1 \
--only-fans-can-comment=0 \
--thumb-media-id "$thumb_media_id" < <workdir>/page.md--jsonmedia_idreferences/notion-search.jsonreferences/cli-commands.mdnotion-clinode-wxcliassets/default.css--format markdown--css-path--page-id--thumb-media-id