使用环境变量配置hexo

在部署hexo博客的过程中,遇到这样一个问题:hexo的部署插件都是在配置文件中配置密钥,而我是使用GitHub Actions进行部署,配置文件也放在仓库中,就会导致部署密钥泄露,所以目前是使用了腾讯的COS部署插件实现,它可以在GitHub Actions中直接调用。

但还是想知道如何在hexo的层面上解决,所以在hexo仓库提交了一个issue

本来以为hexo目前还不支持,后来作者回复可以在自动化流程中使用config命令来实现:

export THEME=next
hexo config theme $THEME

我在hexo网站有搜了下文档,没有相关说明。但是这个命令可以使用:

❯ hexo -h  
INFO  Validating config
Usage: hexo <command>

Commands:
  clean     Remove generated files and cache.
  config    Get or set configurations.
  deploy    Deploy your website.
  generate  Generate static files.
  help      Get help on a command.
  init      Create a new Hexo folder.
  list      List the information of the site
  migrate   Migrate your site from other system to Hexo.
  new       Create a new post.
  publish   Moves a draft post from _drafts to _posts folder.
  render    Render files with renderer plugins.
  server    Start the server.
  version   Display version information.

Global Options:
  --config  Specify config file instead of using _config.yml
  --cwd     Specify the CWD
  --debug   Display all verbose messages in the terminal
  --draft   Display draft posts
  --safe    Disable all plugins and scripts
  --silent  Hide output on console

For more help, you can use 'hexo help [command]' for the detailed information
or you can check the docs: http://hexo.io/docs/

❯ hexo help config
INFO  Validating config
Usage: hexo config [name] [value]

Description:
Get or set configurations.

Arguments:
  name   Setting name. Leave it blank if you want to show all configurations.
  value  New value of a setting. Leave it blank if you just want to show a single configuration.

获取theme的配置:

❯ hexo config theme
INFO  Validating config
next

如果需要设置某一项的子项,比如related_posts中的enable

❯ hexo config related_posts.enable
INFO  Validating config
true

公众号 | FunIO
微信搜一搜 “funio”,发现更多精彩内容。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值