About hexo, how to pass a variable from generator.js to category.ejs?

36 Views Asked by At

How to pass variable from generator.js in the hexo-generator-category to category.ejs in the layout folder? For example one category.name in site.categories.

How to modify this code?

return locals.categories.reduce((result, category) => {
if (!category.length) return result;

const posts = category.posts.sort(orderBy);
const data = pagination(category.path, posts, {
  perPage,
  layout: ['category', 'archive', 'index'],
  format: paginationDir + '/%d/',
  data: {
    category: category.name
  }
});

Is there any other way to achieve the goal?

0

There are 0 best solutions below