Note
This article was automatically translated using Google
I upgraded hexo to 6.3.0 during the day, but it’s still boring at night, and the outside is still very dangerous, so I just put this function is realized, this problem has always existed, However, due to laziness, it dragged on for nearly a year.
Let me briefly introduce that my website has three navigations belonging to three categories
, so when entering the article, the titles and links of the previous and next pages in the footer are actually in the order of date
for all articles as a whole Arranged, so for example, if you click on the next page in the essay, you may click on the article in the experience sharing, which is a bit of a drama. Solve that problem tonight.
Since each person’s theme is different, the writing method of ejs
corresponding to the article page may also be different, here is the original code to explain it (it’s ugly, definitely not the best practice, but it can be used, some masters see it and want to help I’ll optimize it and ask for a message [laughing])
I commented out the ejs syntax and html syntax, in order to better display the js code
This is written in the post.ejs file
1 | var tmpNext = page.next; //Give the next page object of the current page to a variable |
I found that it is not clear to use the source code, it is also because I wrote too violently, let me briefly explain:
- First judge whether there is a next page
- Then judge whether the classification of the current page and the next page are consistent, if not, find the next big complaint
- When the current page is consistent with the next page, then judge whether it is a novel category, if not, it will be it directly
- When the current page is a novel classification, then judge the second-level classification (my novels are stored in collections according to the second-level classification), if not, find the next big complaint
- The current page is a novel category, and it belongs to a collection, that’s it
This perfectly fulfills my needs:
- Essays and experience classification All articles are linked to the next page
- Classification of novels is linked to the next page by collection
I think there is a better way of writing, and other topics should have the same needs as mine, but since I like this topic, I am too lazy to study other topics. After all, the most important thing about a personal website is the content, so use it first if it can satisfy the function.