大家好,
我使用 Node.js 工作流通过 Discourse API 将 GitHub 仓库与 Discourse 连接起来。每当有人在仓库中推送 .md 文件时,系统会自动通过 POST 请求 https://{defaultHost}/posts.json 创建 Discourse 主题;如果主题已存在,则通过 PUT 请求 https://{defaultHost}/posts/{id}.json 进行更新。
我在图片处理上遇到了问题:在 GitHub 的 .md 文件中包含图片有几种方式。以下两种情况运行正常,图片已成功上传至 Discourse:
- 图片托管在 https://user-images.githubusercontent.com/ 上
- 图片直接上传到仓库,并在图片链接末尾附加 ?raw=true
https://github.com/[username]/[reponame]/blob/[branch]/image.jpg?raw=true
但以下两种情况无法正常工作:
- 使用了相对链接
relative/path/to/img.jpg - 缺少 ?raw=true 部分
https://github.com/[username]/[reponame]/blob/[branch]/image.jpg
请问有什么方法可以确保 .md 文件中的所有图片都能上传到 Discourse 吗?