本文首先向主题作者 github@JoeyBling 表示衷心地感谢!
作者 Github:JoeyBling,主题:hexo-theme-yilia-plus。

1. 主题的应用与配置

本文博客的根目录为 blog,首先将主题文件夹放入 blog/themes 中,然后在 blog/_config.yml 文件中找到 theme,修改为:

theme: yilia-plus

然后按自己的需要配置 blog/themes/yilia-plus 中的 _config.yml 文件即可。

2. 目录导航配置

首先需要确保 Node.js 版本大于 6.2,然后在博客根目录 blog 中执行以下命令:

npm i hexo-generator-json-content --save

接着在根目录 blog_config.yml 里添加配置:

jsonContent:meta: falsepages: falseposts:title: truedate: truepath: truetext: falseraw: falsecontent: falseslug: falseupdated: falsecomments: falselink: falsepermalink: falseexcerpt: falsecategories: falsetags: true

3. 文章置顶功能配置

修改根目录 blog 下的 node_modules/hexo-generator-index/lib/generator.js 文件,需要添加以下代码:

posts.data = posts.data.sort(function(a, b) {if(a.top && b.top) {if(a.top == b.top) return b.date - a.date;else return b.top - a.top;}else if(a.top && !b.top) {return -1;}else if(!a.top && b.top) {return 1;}else return b.date - a.date;
});

添加后完整的 generator.js 文件代码如下:

'use strict';const pagination = require('hexo-pagination');
const { sort } = require('timsort');module.exports = function(locals) {const config = this.config;const posts = locals.posts.sort(config.index_generator.order_by);sort(posts.data, (a, b) => (b.sticky || 0) - (a.sticky || 0));posts.data = posts.data.sort(function(a, b) {if(a.top && b.top) {if(a.top == b.top) return b.date - a.date;else return b.top - a.top;}else if(a.top && !b.top) {return -1;}else if(!a.top && b.top) {return 1;}else return b.date - a.date;});const paginationDir = config.pagination_dir || 'page';const path = config.index_generator.path || '';return pagination(path, posts, {perPage: config.index_generator.per_page,layout: ['index', 'archive'],format: paginationDir + '/%d/',data: {__index: true}});
};

配置好后在需要指定的文章中添加 top 属性即可,例如:

---
title: This is title
date: 2022.11.20 11:33
tags: Others
description: This is description
top: true
---

4. 左侧栏添加时钟

blog/themes/yilia-plus/layout/_partial 目录下的 left-col.ejs 文件中添加代码:

<!--时钟-->
<br>
<div style="position:absolute; bottom:120px left:auto; width:100%;height:50%"><script type="text/javascript" src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script><div id="clock" style="font-family: 'Share Tech Mono', monospace;color: #ffffff;text-align: center;position: absolute;left: 50%;top: 50%;-webkit-transform: translate(50%, 50%);transform: translate(-50%, -50%);color: #4B8CE1;text-shadow: 0 0 20px #0aafe6, 0 0 20px rgba(10, 175, 230, 0);"><p style="margin: 0;padding: 0;letter-spacing: 0.1em;font-size: 15px;">{{ date }}</p><p style="margin: 0;padding: 0;letter-spacing: 0.01em;font-size: 38px;">{{ time }}</p></div><script>var clock = new Vue({el: '#clock',data: {time: '',date: ''}});var week = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];var timerID = setInterval(updateTime, 1000);updateTime();function updateTime() {var cd = new Date();clock.time = zeroPadding(cd.getHours(), 2) + ':' + zeroPadding(cd.getMinutes(), 2) + ':' + zeroPadding(cd.getSeconds(), 2);clock.date = zeroPadding(cd.getFullYear(), 4) + '-' + zeroPadding(cd.getMonth() + 1, 2) + '-' + zeroPadding(cd.getDate(), 2) + week[cd.getDay()];};function zeroPadding(num, digit) {var zero = '';for (var i = 0; i < digit; i++) {zero += '0';}return (zero + num).slice(-digit);}</script>
</div>

5. 代码块样式修改

根据 blog/themes/yilia-plus/source-src/css/highlight.scss 文件中的内容相应地修改 blog/themes/yilia-plus/source/main.a5fda8.css 文件即可。

Hexo主题hexo-theme-yilia-plus配置流程相关推荐

  1. 【个人博客】Hexo个人博客搭建与配置详细教程 + Fluid主题 + Gitee发布

    文章目录 一.环境准备 1.1 安装 NodeJs 1.2 安装 Git 1.3 安装 Hexo 二.Gitee仓库搭建 2.1 Gitee账号注册 2.2 仓库搭建 三.Hexo博客搭建 3.1 基 ...

  2. Hexo Yilia 高级配置

    这篇文章列举了搭建博客至今遇到所有问题的解决方法以及一些新功能的添加方法. 这篇文章集合了几乎所有的Hexo Yilia进阶用法教程,包括且不限于: 1.微信分享异常 2."所有文章&quo ...

  3. hexo博客的yilia主题之添加分类

    文章目录 添加 categories 页面 生成index.md文件 修改index.md文件 添加 categories 到menu菜单 yilia 主题的配置文件 main.826e88.css ...

  4. Hexo 主题配置 - NexT

    hexo-theme-next 主题配置大全,图文并茂,持续更新中. 1 安装 NexT 主题 参考 hexo-theme-next 主题官网 1.1 下载 NexT 主题 建议你使用 克隆最新版本 ...

  5. Hexo 主题配置 - Icarus

    hexo-theme-icarus 主题配置大全,图文并茂,持续更新中. 官方效果图: 我的站点:https://cxy35.com 1 安装 Icarus 主题 参考 hexo-theme-icar ...

  6. 搭建博客hexo 安装hexo、配置hexo、hexo主题美化和添加live2d看板娘--详细步骤

    一.安装hexo 1.下载安装软件      git:https://git-scm.com/downloads      node:https://nodejs.org/en/ 2.安装好两个工具之 ...

  7. 设置版权声明html,在Hexo中自动为Yilia主题增加版权声明

    起因 写独立个人博客在与别人分享自己的经验和心情的同时,也要保护自己的权益.在文章的结尾为文章添加版权申明,明确的告知了他人可以获得怎样的许可,有朝一日也为自己以后维护权益提供了便利. 本文介绍在Yi ...

  8. hexo主题之hexo-theme-yilia-plus

    hexo-theme-yilia-plus 一个简洁优雅的hexo主题 ➡️ https://github.com/JoeyBling/hexo-theme-yilia-plus 此项目是根据hexo ...

  9. Hexo主题插入音乐之aplayer音乐播放器

    原文首发自:https://wiki.hushhw.cn/posts/a84d1ef1.html 今天折腾的点是给博客中插入音乐,找到的具体可行的方案有: 使用音乐平台提供的插件 体验很差 使用hex ...

  10. Hexo主题之livemylife个性化构建你的博客

    本篇博客已首发在个人博客 [快乐码原] :Hexo主题之livemylife个性化构建你的博客 欢迎各位客官来康康~ tips:部分图片加载异常,可以到我的个人博客浏览完整版. 简介 livemyli ...

最新文章

  1. iOS - 修改 UITextField 的 clearButtton 样式
  2. 1.2.5 计算机系统的多级层次结构(硬联逻辑级、微程序级、传统机器级、操作系统级、汇编语言级、高级语言级、应用语言级)
  3. java窗体设置最小宽度_flex web Application设置最小高度和宽度。
  4. 借助FLASH技术美化VBA操作界面
  5. 笔记 GWAS 操作流程2-1:缺失质控
  6. 在论文中如何设置页眉页脚
  7. OpenCV——图像窗口namedWindow
  8. MMDetection 基准测试 和 Model Zoo | 三
  9. 关于MFC程序中隐藏任务栏图标的问题
  10. php无法获取操作系统信息,如何获取操作系统信息
  11. UTC和GMT时间辨析
  12. 简单的银行利息代码(已知存不同年份利息)
  13. 使用“git commit -m“命令时候报error
  14. 6U CPCI平台学习资料第116篇:基于5VLX110T FPGA FMC接口功能验证6U CPCI平台
  15. 写5个数学建模的经典模型案例和代码
  16. 联合证券|五大国际巨鳄集体爆雷,美股期指大跳水!
  17. java毕业设计随心淘网管理系统源码+lw文档+mybatis+系统+mysql数据库+调试
  18. Adobe XD 2023(XD 55)安装教程
  19. 扔掉鼠标吧!试着用命令行操作 macOS!
  20. c语言中typeof用法,C++ typeof基本应用方式解析

热门文章

  1. QT界面免费版开源图片转文字工具程序完整版附源码
  2. idea篇:idea快捷键设置
  3. linux显示最近十条命令,10条命令,一分钟分析Linux性能问题
  4. 全球软件工程师薪金最高的25家公司
  5. 威纶通触摸屏与S7-1200以太网通信的具体方法和步骤(非常详细)
  6. kali Linux 黑安卓,黑苹果不再孤单,iPhone成功运行“黑安卓”(附教程)
  7. 加班时间这么短深感惭愧
  8. TabLayout的基本用法(一)
  9. 一周cp未能连接到服务器,AppSight - 一周CP-拒接闲聊只走心
  10. Win10安装.net framework 3.5,提示错误代码0x8000FFF