从木木木木木的博客上发现两篇有意思的文章,于是决定把博客小小改造下。自动化部署,真的就全web界面写博客了;字体异步加载,提高页面载入速度,很早就有这个想法,这次总算比较优雅地解决了。
博客自动化部署
既然选择了coding作为仓库,顺手采用他家的构建计划,和github actions异曲同工。直接贴出.Jenkinsfile
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 
 | pipeline {agent any
 stages {
 stage('检出') {
 steps {
 checkout([
 $class: 'GitSCM',
 branches: [[name: env.GIT_BUILD_REF]],
 doGenerateSubmoduleConfigurations: false,
 extensions: [[$class: 'SubmoduleOption',
 disableSubmodules: false,
 parentCredentials: false,
 recursiveSubmodules: false,
 reference: '',
 trackingSubmodules: false
 ]],
 submoduleCfg: [],
 userRemoteConfigs: [[
 url: env.GIT_REPO_URL,
 credentialsId: env.CREDENTIALS_ID
 ]]])
 }
 }
 stage('安装依赖') {
 steps {
 sh 'npm install -g hexo-cli'
 sh 'npm install'
 }
 }
 stage('自动部署') {
 steps {
 sh 'npx gulp deploy'
 }
 }
 }
 }
 
 | 
值得一提的是,next主题需要作为submodule一同checkout,deploy使用gulp脚本,生成、压缩、上传一条龙。这里有个坑,hexo deploy插件的配置需要使用第二种形式。
异步加载字体文件
只需要在link标签增加两个属性即可解决这个问题。
| <link rel="stylesheet" href="https://fonts.loli.net/css?family=Source+Sans+Pro:300" media="print" onload="this.media='all'">
 | 
参考链接
Hugo + Github Actions 实现自动化部署
添加 Google Fonts 思源宋体
Implicitly loading submodules in Jenkins pipeline stages