Closed visioncan closed 10 years ago
Tag plugins don't support for async callback because Hexo uses Swig as template engine.
You can try the filter, it's more flexible and supports async callback. For example, this is how titlecase works:
var titlecase = hexo.util.titlecase;
hexo.extend.filter.register('pre', function(data, callback){
if (!hexo.config.titlecase || !data.title) return callback();
data.title = titlecase(data.title);
callback(null, data);
});
OK, got it! I will try. Thank you ~
I made it. https://github.com/visioncan/hexo-tag-flickr :stuck_out_tongue_closed_eyes:
Brilliant combination of filter and tag!
hahaha! actually, I'm not sure whether this is optimal or another solution to do it?
@tommy351 And now filter plugins don't have async method. Am I missing something?
@akfish Filter plugins still support async method. You need to use promise instead.
@tommy351 Thanks for the information.
I'm tried to extend Tag plugin for
<img>
tag from Filckr, I useasync
andrequest
to fetch FlickrAPI json. but callback can't waiting for output. I think that is because of async.How can make this work? thank you and your awesome Hexo! :smile: