Hexo配置

配置步骤
- 创建github pages
- 创建本地hexo环境
- 选择hexo主题
- 优化配置

创建github pages

登录github,创建一个新的repository,但仓库名的格式必须为:github账号名.github.io

创建hexo环境

  1. hexo需要用到nodejs,因此先去nodejs官网安装nodejs环境
  2. 按照hexo官网按照hexo
  3. 建站,安装完Hexo后,在执行下列命令,Hexo将会在指定文件夹中新建所需要的文件。
$ hexo init <folder>
$ cd <folder>
$ npm install

更多配置信息,可以参考Hexo文档

选择Hexo主题

我使用的是Next,可以从github上下载https://github.com/iissnan/hexo-theme-next

需要注意的是,按照github上指令安装的版本是5.1.2版本,但如果想添加第三方Valine的评论功能,需要安装5.1.3以上的版本

Next具体细节可以参考Next文档

优化配置

  1. 配置git
    因为要将最新的博客,上传到github上,需要输入以下指令
$ hexo clean
$ hexo g -d

而执行hexo g -d 需要用户输入其相应的github账号名和密码,为了避免每次提交,都输入账号和密码,需要设置SSH keys,具体可以参考廖雪峰git教程
2. 添加评论

这里用到了next中集成的第三方服务

Hexo的评论系统有很多,常见的有
- 多说
- 网易云跟帖
- 畅言
- 来必力(LiveRe)
- Disqus
- Hypercomments
- valine

其中多说和网易云已经失效,而来必力用的是国外服务器,每次加载都很慢,所以建议使用valine

具体可以参考
https://www.bluelzy.com/articles/use_valine_for_your_blog.html
3. 添加动态效果
看到别人使用hexo搭建的博客有酷炫的动态效果,上网搜了一下后发现,其实实现起来很方便

前端效果
https://segmentfault.com/a/1190000009544924
4. 代码高亮
在站点的_config.yml中如下配置

highlight:
  enable: true
  line_number: true
  auto_detect: true
  tab_replace: false

其中tab_replace需要设置成false,tap会全被true替代
5. 代码段折叠

写LeetCode题解时,发现代码太长了,影响阅读,所以想实现一下代码段的折叠

具体参考
https://www.cnblogs.com/woshimrf/p/hexo-fold-block.html

您可以使用com.google.zxing二维码。下面是一个使用Java代码二维码的示例: ```java import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; import com.google.zxing.MultiFormatWriter; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; public class QRCodeGenerator { private static final int QR_CODE_SIZE = 300; public static void generateQRCode(String text, String filePath) throws WriterException, IOException { Map<EncodeHintType, Object> hints = new HashMap<>(); hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); QRCodeWriter qrCodeWriter = new QRCodeWriter(); BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, QR_CODE_SIZE, QR_CODE_SIZE, hints); BufferedImage qrImage = new BufferedImage(QR_CODE_SIZE, QR_CODE_SIZE, BufferedImage.TYPE_INT_RGB); qrImage.createGraphics(); Graphics2D graphics = (Graphics2D) qrImage.getGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, QR_CODE_SIZE, QR_CODE_SIZE); graphics.setColor(Color.BLACK); for (int i = 0; i < QR_CODE_SIZE; i++) { for (int j = 0; j < QR_CODE_SIZE; j++) { if (bitMatrix.get(i, j)) { graphics.fillRect(i, j, 1, 1); } } } ImageIO.write(qrImage, "png", new File(filePath)); } public static void main(String[] args) { String text = "https://www.google.com"; String filePath = "qrcode.png";
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值