2017-12-20 1 views
0

Hexo 블로그를 둘러보기. 각 카테고리의 모든 게시물을 나열하는 카테고리 페이지가 있습니다. 그러나 하나의 범주에 대해 별도의 페이지를 필요로합니다. 여기서 구문에 익숙하지 않습니다. '추천'카테고리에 대해 어떻게 필터링합니까?헥소로 카테고리별로 게시물을 얻는 방법은 무엇입니까?

<div class="archives-wrap" style="margin: 0px;"> 
<div class="archives-category-wrap"> 
    <blockquote> 
    <% if(site.categories.length) { %> 
     <%- list_categories(site.categories) %> 
    <% } %> 
    </blockquote> 
</div> 

<% site.categories.sort('name').map(function(category){ %> 
<div class="archives-wrap"> 
    <div class="archive-year-wrap" id="<%= category.name %>"> 
     <h1 class="archive-category"><%= category.name %></h1> 
    </div> 
    <div class="archives"> 
     <% category.posts.sort('-date').map(function(post, i){ %> 
      <%- partial('_partial/archive-post', {post: post, index: true}) %> 
      <% if (post.subtitle && post.subtitle.length) { %> 
       <h3 class="post-subtitle"> 
        <%- post.subtitle %> 
       </h3> 
      <% } %> 
     <% }) %> 
    </div> 
</div> 
<% }) %> 

답변

0

나도 Hexo에 익숙하지 않은,하지만 난 간단한 IF 문이 작업을 수행해야한다고 생각 :

<div class="archives-wrap" style="margin: 0px;"> 
<div class="archives-category-wrap"> 
    <blockquote> 
    <% if(site.categories.length) { %> 
     <%- list_categories(site.categories) %> 
    <% } %> 
    </blockquote> 
</div> 

<% site.categories.sort('name').map(function(category){ %> 
    <% if(category.name == 'featured') { %> 
     <div class="archives-wrap"> 
      <div class="archive-year-wrap" id="<%= category.name %>"> 
       <h1 class="archive-category"><%= category.name %></h1> 
      </div> 
      <div class="archives"> 
       <% category.posts.sort('-date').map(function(post, i){ %> 
        <%- partial('_partial/archive-post', {post: post, index: true}) %> 
        <% if (post.subtitle && post.subtitle.length) { %> 
         <h3 class="post-subtitle"> 
          <%- post.subtitle %> 
         </h3> 
        <% } %> 
       <% }) %> 
      </div> 
     </div> 
    <% } %> 
<% }) %> 

더 정교한 솔루션은 필터 기능을 사용하는 수를 지도를 만들기 전에 문서에서 이러한 기능을 찾지 못했습니다.

관련 문제