You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
369 B

'use strict';
const { Cache } = require('hexo-util');
module.exports = ctx => {
const cache = new Cache();
// reset cache for watch mode
ctx.on('generateBefore', () => { cache.flush(); });
return function fragmentCache(id, fn) {
if (this.cache) return cache.apply(id, fn);
const result = fn();
cache.set(id, result);
return result;
};
};