Export Github Issues (for bloggers) to markdown file
- 🚀 使用 TypeScript 重写,提供完整的类型支持
- 📦 支持 pnpm 包管理器
- 🎯 Node.js 16.16.0+ 支持
- 🔧 模块化设计,可作为 CLI 工具或 Node.js 库使用
- 🎨 美观的命令行界面,带有进度指示器
- 📄 灵活的 Markdown 输出格式
- Node.js >= 16.16.0
- pnpm >= 8.1.0
pnpm install -g issues2md# 克隆项目
git clone <repository-url>
cd issues2md
# 安装依赖
pnpm install
# 构建项目
pnpm run build
# 开发模式
pnpm run dev导出单个 issue 为 Markdown:
issues2md issue <issue_URL> [options]导出 Github Blog issues 列表为目录:
issues2md toc <blog_URL> [options]导出 Github Blog 所有 issues 为 Markdown 文件:
issues2md articles <blog_URL> [options]-o, --output <dir>: 指定输出目录 (默认:./output)-t, --token <token>: GitHub 访问令牌 (也可通过环境变量GITHUB_TOKEN设置)
# 导出单个 issue
issues2md issue https://github.com/yanyue404/blog/issues/270
# 导出博客目录
issues2md toc https://github.com/yanyue404/blog -o ./my-blog
# 导出所有文章
issues2md articles https://github.com/yanyue404/blog -o ./my-blog
# 使用 GitHub token
issues2md articles https://github.com/yanyue404/blog -t your_github_tokenimport { GitHubClient, MarkdownConverter, exportIssue } from 'issues2md';
// 创建 GitHub 客户端
const client = new GitHubClient({
owner: 'yanyue404',
repo: 'blog',
token: 'your_github_token', // 可选
});
// 获取 issue
const issue = await client.getIssue(270);
// 转换为 Markdown
const converter = new MarkdownConverter();
const markdown = converter.convertIssueToMarkdown(issue);
// 或者直接使用命令函数
await exportIssue('https://github.com/yanyue404/blog/issues/270', {
output: './output',
token: 'your_github_token',
});# 安装依赖
pnpm install
# 开发模式 (监听文件变化)
pnpm run dev
# 构建
pnpm run build
# 代码检查
pnpm run lint
# 修复代码风格问题
pnpm run lint:fix
# 清理构建文件
pnpm run clean如果需要配置网络代理访问:
# 设置环境变量
export https_proxy=http://127.0.0.1:33210
export http_proxy=http://127.0.0.1:33210
# 然后运行命令
issues2md articles https://github.com/yanyue404/blogsrc/
├── commands/ # CLI 命令实现
│ ├── issue.ts # 单个 issue 导出
│ ├── toc.ts # 目录导出
│ └── articles.ts # 批量文章导出
├── utils/ # 工具函数
│ ├── github.ts # GitHub API 客户端
│ └── markdown.ts # Markdown 转换器
├── types/ # TypeScript 类型定义
│ └── index.ts
├── cli.ts # CLI 入口文件
└── index.ts # 库入口文件
MIT