hexo fluid 魔改指南

· · 科技·工程

前言

请搭建好了以后再来食用这篇文章,这篇文章主要讲魔改美化。

对于一些比较基本的修改,官方文档讲的很清楚了,

本人下的是最新版的 fluid。

本地更新博客后请记得在你的文件夹里 Git a Bash,然后输入 hexo cl && hexo g && hexo d。

全屏固定背景图

打开你的博客首页,发现背景图片会因为下翻而滚动,我们可以让他固定不动。

在根目录下创建一个名字叫 scripts 的文件夹,进入文件夹,新建 injector.js。

内容为:

const { root: siteRoot  =  "/" } =  hexo.config;

hexo.extend.injector.register("body_begin", `<div id="web_bg"></div>`);

hexo.extend.injector.register("body_end",`<script src="${siteRoot}js/backgroundize.js"></script>`);

然后打开 source 文件夹,进入,新建一个名字叫 js 的文件夹,新建 backgroundize.js。

内容为:

document
  .querySelector('#web_bg')
  .setAttribute('style', `background-image: ${document.querySelector('.banner').style.background.split(' ')[0]};position: fixed;width: 100%;height: 100%;z-index: -1;background-size: cover;`);

document
  .querySelector("#banner")
  .setAttribute('style', 'background-image: url()')

document
  .querySelector("#banner .mask")
  .setAttribute('style', 'background-color:rgba(0,0,0,0)')

这样就可以固定背景图片了。

左上角标题特效

效果见 https://zhoujunchen666.github.io/ 左上角。

颜色还会变。

来到目录 blog\node_modules\hexo-theme-fluid\source\css\_pages\_base\_widget\header.styl。

打开,末尾加上样式:

.navbar-title
  outline none
  --c lightseagreen
  text-shadow 0 0 10px var(--c),0 0 20px var(--c),0 0 40px var(--c),0 0 80px var(--c),0 0 160px var(--c)
  animation animate 5s linear infinite

@keyframes animate{
  to{
      filter: hue-rotate(360deg)
  }
}

来到 blog\node_modules\hexo-theme-fluid\layout\_partials\header\navigation.ejs,找到 <strong><%= theme.navbar.blog_title || config.title %></strong>,将其修改为 <strong class="navbar-title"><%= theme.navbar.blog_title || config.title %></strong>。

就可以啦。

宣 blog:zhoujunchen666.github.io,咕咕咕。