Update hexo to v6.3.0
2022-12-16 20:29 ≈ 612Words ≈ 3Minutes

Note

This article was automatically translated using Google

In the past few days, I have focused on updating articles, and suddenly found that hexo g displayed a highlight error, because I have been submitting to git to automatically generate articles before, so I have not checked the log carefully

The main reason is that it only reports a warning when it is generated, and it does not affect the use. This time I found out that I wanted to adjust the theme style, so I need to upgrade the plugin (it has not been upgraded for almost a year, and my hexo version is still 5.4, now 6.3)

Upgrade hexo and plugins

There are many ways to upgrade node and npm on the Internet, just search for it

  1. Check the hexo version: hexo version
  2. Global upgrade: npm i hexo-cli -g
  3. Navigate to the hexo directory
  4. Check plugin: npm-check
  5. You can manually upgrade according to the prompt, or directly: npm-upgrade + npm update --save
  6. Check the version number again to confirm: hexo version

Check if the modified place is overwritten

There is no problem with the upgrade itself, but when using it, because I don’t like to write comments, I may manually modify some plug-ins and forget it. This time, it will be overwritten after the upgrade.

There are two main system plug-ins I changed:

hexo-generator-index As mentioned in the article, I removed several categories from the homepage. If I don’t modify them, the paginated pages still contain articles of this category, which will cause the number of articles on the page to be incorrect.

hexo-generator-category, I also changed this, but I forgot it completely, which caused a problem with the sorting in my novel category. I found the reason by directly modifying and comparing with git, sweating…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict';

const pagination = require('hexo-pagination');

module. exports = function(locals) {
const config = this.config;
const perPage = config. category_generator. per_page;
const paginationDir = config.pagination_dir || 'page';
var orderBy = config.category_generator.order_by || '-order'; // use variable var instead of constant

return locals.categories.reduce((result, category) => {
if (!category. length) return result;

//When classified as a novel, manual sorting is used, and others are sorted by default date. This order is written in the Front-matter of the novel md file
//For centralized display of novels in the same category
//Then sort by date in the novel page
if(category.name == 'novel'){
orderBy = config.category_generator.order_by || '-order';
}else{
orderBy = config.category_generator.order_by || '-date';
}

const posts = category. posts. sort(orderBy);
const data = pagination(category. path, posts, {
per Page,
layout: ['category', 'archive', 'index'],
format: paginationDir + '/%d/',
data: {
category: category.name
}
});

return result.concat(data);
}, []);
};

Hurry up and manually record the upgrade process, save it and forget about it when you upgrade later, the final display effect is very good

1671162733620

Remaining problem

In fact, there is still a remaining problem, which is the context address of the article. This address seems to have been created when the system paginated or even earlier, and the original logic is no problem. But I want him to generate three different context-corresponding addresses based on the three categories of essays, experiences, and novels

That is to say, the context of the articles in my essays will not point to the articles in the experience. At present, it is sorted by time globally. This should also find the place to modify, but let’s talk about it in two days.