We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
例如wordpress的is_category()函数可以实现这样的效果:如果是分类A,则显示一段与A相关的简介。 hexo的is_category()辅助函数可以实现么?
The text was updated successfully, but these errors were encountered:
http://hexo.io/docs/helpers.html#is_category
Sorry, something went wrong.
hexo的is_category()只能判断是否是分类归档页面,而不能判断是某个分类(分类A/分类B)的页面。
is_category()
You can use page.category to get the category name.
page.category
8735bfe
下面两个方法,一个是在列表外使用,一个是在列表内使用,<% page.posts 内既是列表内容,反之既是列表外
<% page.posts
以下示例,如果当前列表的分类是网页截图就添加这段行内样式(也可以替换其他任意内容)
网页截图
<% if (is_category('网页截图')) { %> style="columns: 600px;" <% } %>
这段代码可以在文章页模板使用,也可以在各列表使用
用分类名称name判断,将像素教程替换为特定分类名称
name
像素教程
<% post.categories.forEach(category => { %> <% if (category.name == '像素教程') { %> 这是像素教程的内容 <% } %> <% }); %>
more: Hexo 笔记 | 像素教程 1px.run
No branches or pull requests
例如wordpress的is_category()函数可以实现这样的效果:如果是分类A,则显示一段与A相关的简介。
hexo的is_category()辅助函数可以实现么?
The text was updated successfully, but these errors were encountered: