# hexo-source **Repository Path**: zhyihui/hexo-source ## Basic Information - **Project Name**: hexo-source - **Description**: Github Pages 个人博客源文件 - **Primary Language**: NodeJS - **License**: Not specified - **Default Branch**: master - **Homepage**: https://zhyihui.github.io/ - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-03-20 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Hexo 个人博客源码 [个人博客](https://zhyihui.github.io/) 本项目是托管在Github Pages上的个人博客的源文件,在每次部署后使用脚本自动备份。 ## 安装说明 将本博客源码项目Clone到本地,进入项目目录后执行npm install即可安装相关依赖。 然后需要当前使用的主题yelee,[Yelee主题使用说明](http://moxfive.coding.me/yelee/1.Getting-Started/installation.html) ```bash git clone https://github.com/MOxFIVE/hexo-theme-yelee.git themes/yelee ``` 最后运行即可 ```bash hexo clean && hexo s ``` ### 使用说明 生成静态页面 ```bash hexo generate ``` 新建文章 ```bash hexo new post "title" ``` 部署 ```bash hexo deploy ``` 清除生成的文件和缓存 ```bash hexo clean ``` ## 自动备份 - [Hexo Events](https://hexo.io/api/events.html) - [自动备份Hexo博客源文件](http://zhujiegao.com/2015/12/06/automatic-backup/) 通过通过监听Hexo的其它事件来完成自动执行Git命令完成自动备份,脚本文件在 `scripts` 目录中。 ```javascript require('shelljs/global') try { hexo.on('deployAfter', function() { //当deploy完成后执行备份 runBackup(); }); } catch (e) { console.log("自去备份源码出现错误!,错误详情:" + e.toString()); } function runBackup() { if (!which('git')) { echo('你需要安装Git.'); exit(1); } echo(">>>>>>>>>>>>>>>>> 自动备份博客源码开始 <<<<<<<<<<<<<<<<<"); cd("E:\\workspaces\\blog"); if (exec('git add --all').code !== 0) { echo('Error: Git add failed'); exit(1); } if (exec('git commit -am "From auto backup script\'s commit"').code !== 0) { echo('Error: Git commit failed'); exit(1); } if (exec('git push origin master').code !== 0) { echo('Error: Git push failed'); exit(1); } echo(">>>>>>>>>>>>>>>>> 自动备份博客源码结束 <<<<<<<<<<<<<<<<<"); } ``` 脚本使用了 [shelljs](https://www.npmjs.com/package/shelljs) 模块,该模块重新包装了child_process,使我们调用系统命令更加方便。