Hexo DIY

Adding customized features

Pin/Unpin a post

Pin or unpin a post in any order by modifying the source code:

  • Open the “node_modules\hexo-generator-index\lib”, then modify the sorting function in “generator.js”;
  • Pin or unpin a post by setting the “top” variable.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module.exports = function(locals) {
const config = this.config;
const posts = locals.posts.sort(config.index_generator.order_by);

// posts.data.sort((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;
})

Edit the layout

Please Edit the style files (base.styl and responsive.styl) under the path “node_modules\hexo-theme-icarus\include\style”.

Rendering mathematical formulas

Some symbols in the formula are being escaped by Hexo’s Markdown processor, so the formula received by MathJax is incorrect. To solve this problem, you can use the code block to wrap the problematic formula.

Add Night theme

Icons for Markdown

Author

Jie Sun

Posted on

2023-09-17

Updated on

2024-03-31

Licensed under

Comments