2017-09-13 50 views
0

我想用hexo對分類進行分組。雖然hexo <%list_categories%>幫手列出我所有的類別沒問題,我想分組嵌套類別的權利。以hexo分組類別

我的問題是在兩個層面上,首先,你如何表達前端的子類別。換句話說,我將如何將子類別[motosport,cricket,basketball,hockey]添加到以下前端內容中。 體育是主要類別

categories: 
    - sports 

兩個,我怎麼通過所有類別和每個孩子的枚舉。我是否仍然使用此代碼

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

還是有更好的方法/功能嗎?

+0

這個主題支持childCategories你可以看看它是如何做https://github.com/LouisBarranqueiro/hexo-theme-tranquilpeak/blob/master/layout/all-categories.ejs –

+0

我檢查,我仍然有一個問題,因爲沒有實際的例子說明你如何在實際的項目中支持這種支持。我的意思是,你如何在前面的問題中編寫子類? – One

+0

嘗試'父類:MyCategory'在前面的問題 上分類-filter.js 'this.dataCategory = '類別';'' this.dataParentCategories = '父類別';' –

回答

1
  1. In Hexo v3.3.9 added hierarchical categories feature。需要更新hexo/node_modules/hexo/lib/models/post.jsthis commit(或更新,如果存在)。而這樣設置的類別(在*.md):

    categories: 
    - [sport, motosport] 
    - [sport, cricket] 
    - [sport, basketball] 
    - [sport, hockey] 
    
  2. <%- list_categories() %>不帶任何參數枚舉的父母和他們的孩子的已經在分級列表; <%- list_categories(site.categories, {depth: 1}) %>枚舉只有父母(體育)的網站總數等現在的完整選項here