本文首先向主题作者 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. Kotlin极简教程:第10章 Kotlin与Java互操作
  2. Re:从0开始的微服务架构:(一)重识微服务架构--转
  3. 推荐系统中如何做多目标优化
  4. Multi-tenant or multi-instance?
  5. ML.NET Cookbook:(20)我如何定义自己的数据转换?
  6. 单独安装想要的office_安装OFFICE不再求人,最省心的方法
  7. pdfjs viewer 开发小结
  8. 湖北工业大学计算机学院王泽建,“指尖年轮,感恩成长”计算机学院2019届毕业生晚会圆满举行...
  9. TensorFlow 学习初步-环境搭建
  10. JAVA基础之JDK、JRE、JVM关系
  11. 软件工程概论--课后作业1
  12. 小区物业管理系统--数据库应用开发
  13. 内嵌式串口转WiFi模块
  14. c语言大一,C语言复习 大一.doc
  15. 我用MOS管做开关管却不能关闭?
  16. excel 日期选择器_Excel日期选择器工具
  17. Tiny210--3--基于Tiny210的CMOS摄像头图像采集
  18. 电脑连接树莓派3B+
  19. 经纬度和高德地图计算两点距离面积
  20. adb命令查看应用权限赋予情况

热门文章

  1. C++ 完美破解九宫格(数独)游戏
  2. 新款IBM POWER8服务器通过NVLINK与Tesla P100互联
  3. 什么是TCP/IP?-四张图解释TCP/IP四层协议模型
  4. 手写稿怎么变成电子稿?这个办法值得一试
  5. 数据库导入.sql文件
  6. WebConfig中的sessionState设置之不理
  7. mysql有闪回吗_MySQL的闪回策略
  8. Kalman滤波器初学者入门
  9. matlab保存读取矩阵
  10. 计算机科学技术学院博逸楼,逍遥二路(宁夏路)附近校内附属设施