hexo-butterfly-swiper-anzhiyu
Version:
A Slideshow plugin for theme-butterfly based on swiper
14 lines (13 loc) • 443 B
JavaScript
hexo.extend.generator.register('random', function (locals) {
const config = hexo.config.random || {};
const posts = [];
for (const post of locals.posts.data) {
if (post.random !== false) posts.push(post.path);
}
return {
path: config.path || 'anzhiyu/random.js',
data: `var posts=${JSON.stringify(
posts
)};function toRandomPost(){pjax.loadUrl('/'+posts[Math.floor(Math.random() * posts.length)]);};`,
};
});