一套内容多平台发布工具,帮助技术博主将 Markdown 文章快速发布到 GitHub Pages 博客和 Dev.to 开发者社区,同时提供 SEO 优化和发布前去重检查。
check_duplicate 方法可手动调用检查复制 config.yaml.example 为 config.yaml,填入你的 API 密钥:
yaml
github:
token: "ghp_xxxxxxxxxxxx" # GitHub Personal Access Token
repo: "username.github.io" # 博客仓库名 (格式: 用户名/仓库名)
devto:
api_key: "xxxxxxxxxx" # Dev.to API Key
获取 API 密钥:
bash
pip install -r requirements.txt
bash
python publish.py --article ./article.md
bash
python publish.py --article ./article.md --dry-run
bash
# 仅发布到博客
python publish.py --article ./article.md --platforms blog
# 仅发布到 Dev.to
python publish.py --article ./article.md --platforms devto
# 同时发布到两个平台
python publish.py --article ./article.md --platforms all
bash
python publish.py --config /path/to/config.yaml --article ./article.md
text
python publish.py [选项]
必需参数:
--article, -a 文章文件路径
可选参数:
--config, -c 配置文件路径 (默认: config.yaml)
--platforms, -p 发布平台: all / blog / devto (默认: all)
--mode, -m 发布模式: full / summary / abstract / auto (默认: auto)
--dry-run, -d 预览模式,不实际发布
--verbose, -v 详细输出
创建 Markdown 文件,包含 YAML front matter:
markdown
---
title: "文章标题"
date: 2026-05-23
tags: ["技术", "AI", "教程"]
cover_image: "./assets/cover.jpg"
---
文章正文内容...
支持的 front matter 字段:
字段必需说明title是文章标题date否发布日期(默认为当前日期)tags否标签列表cover_image否封面图片路径excerpt否自定义摘要(不填则自动提取前 200 字)
text
content-publisher/
├── SKILL.md # 技能描述文件
├── README.md # 使用文档
├── LICENSE # MIT 许可协议
├── publish.py # 主程序入口
├── config.yaml.example # 配置文件示例
├── requirements.txt # Python 依赖
├── utils/
│ ├── __init__.py
│ ├── github_publisher.py # GitHub Pages 发布模块
│ ├── devto_publisher.py # Dev.to 发布模块
│ ├── content_processor.py # 内容解析与差异化处理
│ └── seo_optimizer.py # SEO 优化模块
├── templates/
│ ├── blog_template.md # 博客文章模板
│ └── devto_template.md # Dev.to 文章模板
└── examples/
├── sample-article.md # 示例文章
└── sample-config.yaml # 示例配置
编辑 templates/ 目录下的模板文件,自定义各平台发布格式。
使用系统定时任务(cron):
bash
# 每天上午 9 点自动发布
0 9 * * * cd /path/to/content && python publish.py --article ./today.md
bash
# 发布目录下所有 Markdown 文章
for file in ./articles/*.md; do
python publish.py --article "$file"
done
config.yaml 提交到公共仓库(已在 .gitignore 中忽略)--verbose 查看详细错误信息--dry-run 预览发布内容MIT License - 详见 LICENSE 文件