Tiny filter plugin for Hexo to query posts.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
index.js
package.json

README.md

hexo-filter-api

Tiny Hexo filter plugin to query posts. Used in theme Lightpush.

Installation

$ npm install hexo-filter-api --save

or clone the master branch

git clone https://github.com/medicor/hexo-filter-api node_modules/hexo-filter-api

and update with

cd node_modules/hexo-filter-api
git pull

Example of usage

$('#search-input').keyup(function() {
	var me = $(this);
	
	function run() {
		var qs = me.val();
		if (qs.length > 1) {
			$.get('/api/posts/?q=' + qs).done(function(aResponse) {
				var rs = $('#search-results');
				rs.children().remove();
				if (aResponse.length === 0) {
					rs.append('<div class="search-noresult">(no matching posts found)</div>');
				} else {
					aResponse.forEach(function(anItem) {
						rs.append('<a href="/' + anItem.path + '"><span class="fa fa-newspaper-o"></span>&nbsp;' + anItem.title + '</a>');
					});
				}
			});
		}
	}
	clearTimeout(me.data('timer'));
	me.data('timer', setTimeout(run, 500));
});