Lemonreds / hexo-theme-nayo

一个简洁的Hexo主题.

Home Page:http://lemonreds.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Categories页面不能正常显示

JiuMingZhu opened this issue · comments

对照着tag页面的layout依葫芦画瓢把
"xxx\themes\hexo-theme-nayo\layout\category.ejs"
改为如下代码

<section>

  <% if( is_category()){ %>

  	<span class="page-title"><%=  "# "+ page.category %></span>

  	 <% page.posts.each(function (post) { %>  

        <%- partial('_partial/_common/item',{post:post}) %>       

  	 <% }) %> 	
  <%}else {%>    
      
        <span class="page-title"><%=  __('Page.Categories') %></span> 
        
        <% site.categories.sort('date',-1).each( function (category){%>
            
            <a class="category-wrap slideDownMin " href="<%- url_for(category.path) %>">    
            <span class="iconfont icon-category-inner"></span>           
               <span class="category-name"> <%- category.name %> </span>
               <span class="category-count"><%- category.length %></span>  
             </a>
        <% })%>

    <%}%>	    
</section>

启用categories
hexo new page categories
然后找到对应的index.md
编辑如下

---
title: categories
date: 2018-06-30 19:10:40
type: "categories"
layout: "category"
---

因为作者在他的模板里面是cateory,所以这边的layout不要写错
参照:#13

主题的配置文件中不要忘记改了

menu:
  home: /
  archives: archives
  categories: categories
  tags: tags
  about: about
  search: search

更改完之后category可以正常显示啦
图例
应该是我依葫芦画瓢样式没选择对,不过总算是能正常显示界面了:P

commented

那categories 可以实现多级分类嘛? @JiuMingZhu

commented

我是小白。。具体怎么实现呢? @JiuMingZhu