本地变量

模板渲染使用局部变量,即模板中的 site 变量。

¥Local variables are used for template rendering, which is the site variable in templates.

默认变量

¥Default Variables

变量 描述
posts 所有帖子
pages 所有页面
categories 所有类别
tags 所有标签

获取变量

¥Get a Variable

hexo.locals.get("posts");

设置变量

¥Set a Variable

hexo.locals.set('posts', function(){
return ...
});

删除变量

¥Remove a Variable

hexo.locals.remove("posts");

获取所有变量

¥Get All Variable

hexo.locals.toObject();

使缓存无效

¥Invalidate the cache

hexo.locals.invalidate();