Note
This article was automatically translated using Google
Hexo has been set up for 6 days, and it feels very good for normal use. Today, I found a problem. When using full-text search, if your current page is not the homepage, then the searched address is wrong.
I tracked down the wrong address and found that it was caused by the addition of the current address.
Take my website as an example, for example, the current address is: https://www.igerm.ee/categories/gossip/
, and then I just search for a content
The actual address of the first article should be: https://www.igerm.ee/2021/04/04/tech/Hexo beautification optimization extreme tracking/
But the address added in the a
tag is: https://www.igerm.ee/categories/gossip/2021/04/04/tech/Hexo beautification and optimization to chase points/
This makes it impossible to enter the article by clicking the title Page, and entered the 404 page
Preliminary guess may be caused by the automatic splicing of addresses. Looking at the source code, I believe that if there is no special requirement in the search
part, everyone’s source code is copied from the official plug-in demo
, then ours should be the same, from the isMatch'
Part start:
1 | if (isMatch) { |
The str
in the second line is where the a
tag is output. You can see that I have added "<%- theme.avatar.path %>"
in front, because the address in data_url
is the address of the article Remove the part of the website address. If you don’t complete the URL in front, then the page will automatically be spliced with the address of the current page, which also caused the error mentioned above. Here I spliced the main address of my own website completely. Then the searched address will be no problem.