Skip to content

feat(图床): 图片替换支持腾讯云图床、阿里云图床、七牛云图床 #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 17, 2022

Conversation

LetTTGACO
Copy link
Collaborator

@LetTTGACO LetTTGACO commented Feb 12, 2022

改造思路:https://1874.cool/nvikqw/

配置 图床TOKEN(可选)

语雀的url存在防盗链的问题,直接部署可能导致图片无法加载。
如果需要语雀URL上传到图床中并替换原链接,就需要配置上传密钥。

访问图床的密钥管理获取密钥,然后传入密钥到yuque-hexo

  • 腾讯云API密钥管理

  • 阿里云API密钥管理

  • 七牛云API密钥管理

  • 在设置YUQUE_TOKEN的基础上配置SECRET_ID和SECRET_KEY

  • 命令执行时传入环境变量

    • mac / linux: YUQUE_TOKEN=xxx SECRET_ID=xxx SECRET_KEY=xxx yuque-hexo sync
    • windows: set YUQUE_TOKEN=xxx SECRET_ID=xxx SECRET_KEY=xxx && yuque-hexo sync

imgCdn 语雀图片转图床配置说明

注意:开启后会将匹配到的所有的图片都上传到COS

参数名 含义 默认值
enabled 是否开启 false
imageBed 选择将图片上传的图床,目前支持腾讯云(cos)、阿里云(oss)和七牛云(qiniu),默认使用七牛云 'qiniu'
host 使用七牛云图床时,需要指定CDN域名前缀
bucket 图床的bucket名称 -
region 图床的的region -
prefixKey 文件前缀 -

host 说明

由于七牛云默认使用CND进行图片外链访问(默认提供30天的临时域名或者添加自定义CDN域名),所以需要指定访问的域名前缀
例如:'host': http://image.1874.cool,域名后面不需要加斜杠

bucket和region说明

获取腾讯云的bucket和region,示例:{ bucket: "blog", region: "ap-guangzhou" }

获取阿里云的bucket和region,示例:{ bucket: "blog", region: "oss-cn-shenzhen" }

获取七牛云的bucket(空间)和region(机房),示例:{ bucket: "blog", region: "Zone_z2" }

七牛云机房取值: 华东(Zone_z0)华北(Zone_z0)华南(Zone_z0)北美(Zone_z0)

prefixKey 说明

如果需要将图片上传到图床的根目录,那么prefixKey不用配置。

如果想上传到指定目录blog/image下,则需要配置prefixKey为"prefixKey": "blog/image"。

目录名前后都不需要加斜杠

@x-cold
Copy link
Owner

x-cold commented Feb 14, 2022

CI 貌似有问题,辛苦再看下

@LetTTGACO
Copy link
Collaborator Author

https://www.yuque.com/yinzhi/yuque-hexo-demo这个访问不了导致我本地CI跑的时候下载不了文章

@LetTTGACO LetTTGACO merged commit 2d14487 into x-cold:master Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants