在hexo中分组类别 [英] Grouping categories in hexo

查看:120
本文介绍了在hexo中分组类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用十六进制对类别进行分组.虽然hexo <%list_categories%> 助手会列出我的所有类别,但我想将嵌套类别正确分组.

I would like to group categories in hexo. While the hexo <% list_categories %> helper lists all my categories alright, I would like to group nested categories right.

我的问题有两个层次,首先,您如何表示前端事物中的子类别.换句话说,我如何将子类别[motosport,板球,篮球,曲棍球]添加到以下重要内容中. 体育是主要类别

My question is on two levels, first, how do you represent the subcategories in the front matter. In other words, how would I add the subcategories [motosport, cricket, basketball, hockey] into the following front matter. sports is the main category

categories:
  - sports

二,我如何列举所有类别及其每个孩子.我仍然使用此代码吗?

Two, how do I enumerate through all categories and each of their children. Do I still use this code

<%- list_categories(site.categories, { options}); %>

还是有更好的方法/功能?

or is there a better way/function?

推荐答案

  1. Hexo v3.3.9 中添加了分层类别功能.需要通过此提交(或更新,如果存在)进行更新.并设置这样的类别(在*.md中):

  1. In Hexo v3.3.9 added hierarchical categories feature. Need to update hexo/node_modules/hexo/lib/models/post.js by this commit (or newer if exists). And set categories like this (in *.md):

categories:
- [sport, motosport]
- [sport, cricket]
- [sport, basketball]
- [sport, hockey]

没有任何参数的

  • <%- list_categories() %>会枚举已经在层次结构列表中的父母及其子女; <%- list_categories(site.categories, {depth: 1}) %>仅枚举网站总数的父项(体育),等等.暂时提供完整选项此处.
  • <%- list_categories() %> without any parameters enumerate parents and their childs already in hierarchical list; <%- list_categories(site.categories, {depth: 1}) %> enum only parents (sport) of site total, etc. Full options for now here.
  • 这篇关于在hexo中分组类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆