Skip to content

Commit

Permalink
分类展示具体列表
Browse files Browse the repository at this point in the history
  • Loading branch information
woheme committed Jun 4, 2015
1 parent 9e31b64 commit 8fd445f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
8 changes: 6 additions & 2 deletions _config.yml.site.example
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ default_category: uncategorized
category_map:
tag_map:

# Archives 默认值为2,这里都修改为1,相应页面就只会列出标题,而非全文
## 2: Enable pagination
## 1: Disable pagination
## 0: Fully Disable
archive: 1
category: 2
tag: 2
category: 1
tag: 1

# Date / Time format
## Hexo uses Moment.js to parse and display date
Expand Down
45 changes: 41 additions & 4 deletions layout/_partial/archive.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
</nav>
<% } %>
<% } else { %>
<% var last; %>
<% site.posts.sort('date', 'desc').each(function(post, i){ %>
<% if (is_archive()){ %>
<% var last; %>
<% site.posts.sort('date', 'desc').each(function(post){ %>
<% var year = post.date.year(); %>
<% if (page.year === undefined || page.year == year){ %>
<% if (page.month === undefined || page.month == post.date.format('M')){ %>
Expand All @@ -26,11 +28,46 @@
<article class="article-simple" itemscope="" itemprop="blogPost">
<div class="article-simple-inner article-inner">
<header class="article-simple-header">
<a class="article-simple-title" href="<%- url_for(post.path) %>"><span class="article-simple-span"><%- post.date. format('MM-DD') %></span><%- post.title %></a>
<a class="article-simple-title" href="<%- url_for(post.path) %>">
<span class="article-simple-span"><%- post.date.format('MM-DD') %></span>
<%- post.title %></a>
</header>
</div>
</article>
<% } %>
<% } %>
<% }) %>
<% }) %>
<% } %>
<% if (is_category()){ %>
<div class="archive-list-year-wrap">
<i class="fa fa-archive"></i>
<a href="<%- url_for('categories/' + page.category) %>" class="archive-year"><%- page.category %></a>
</div>
<% site.posts.sort('date', 'desc').each(function(post){ %>
<% var category; %>
<% if (post.categories && post.categories['data'] && post.categories['data'][0] && post.categories['data'][0]['name']){ %>
<% category = post.categories['data'][0]['name']; %>
<% } else { %>
<% return; %>
<% } %>
<% if (category != page.category){ %>
<% return; %>
<% } %>
<article class="article-simple" itemscope="" itemprop="blogPost">
<div class="article-simple-inner article-inner">
<header class="article-simple-header">
<a class="article-simple-title" href="<%- url_for(post.path) %>">
<span class="article-simple-span"><%- post.date.format('MM-DD') %></span>
<%- post.title %>
</a>
</header>
</div>
</article>
<% }) %>
<% } %>
<% } %>

0 comments on commit 8fd445f

Please sign in to comment.