Content Filtering with Hexo Tipue-Search Engine
It's always been a headache to me that I cannot have my blog's search engine to show content I want — there're always something you don't want 'em to show up in a search result, like password protected posts (shown as encrypted codes) and random pages for a certain project (some even don't have a title, and this tipue-search would still show them in the searching result — with a blank title and a bunch of html raw codes). Even worse, it seems there's no offical way to set this sort of content filters. This feels bad. This terrible feeling has tortured me for months till I made up my mind and fixed it from source codes today.
The fix turned out, well, quite straightforward. First, we locate the node package folder
hexo-generator-tipue-search-json. The package structure shows
node_modules └───hexo-generator-tipue-search-json ├───index.js ├───LICENSE ├───package.json ├───README.md └───node_modules └───...
The file we need to edit is
index.js. Below I've attached the full codes after modification:
var util = require('hexo-util');
Note the second line of the definition of
postsContent and the lines we comment out. These modifications are made such that encrypted posts and standalone pages won't be searched.