2017-12-20 9 views
0

Hexoのブログを使いこなしています。カテゴリページには、各カテゴリのすべての投稿が一覧表示されています。しかし、私は別のページを1つのカテゴリに固有のものにしたい。私はここでの構文に慣れていない。 「特集」と呼ばれるカテゴリをフィルタリングするにはどうすればよいですか?ヘキソを使ってカテゴリ別に投稿するには?

<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> 
    <% } %> 
<% }) %> 

より精巧な解決策は、フィルタ機能を使用することができマップの前に、私はそのドキュメントでそのような機能を見つけられませんでした。

関連する問題