Skip to content

Commit

Permalink
[categories] page and category page work
Browse files Browse the repository at this point in the history
  • Loading branch information
CatherineLiyuankun committed Feb 15, 2019
1 parent 86d52a8 commit 5005553
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 48 deletions.
44 changes: 44 additions & 0 deletions themes/zilan/layout/_partial/archive.ejs
@@ -0,0 +1,44 @@
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<%
var title = '';
if (page.category) title = page.category;
if (page.tag) title = page.tag;
if (page.archive) {
if (page.year) title = page.year + (page.month ? '/' + page.month : '');
else title = __('archive_a');
}
%>
<h2 class="archive-title<% if (page.tag){ %> tag<% } else if (page.category){ %> category<% } %>"><%= title %></h2>
<% if (pagination == 2){ %>
<% page.posts.each(function(item){ %>
<%- partial('article', {item: item, index: true}) %>
<% }); %>
<%- partial('pagination') %>
<% } else { %>
<% var this_year; %>
<article class="archive">
<% page.posts.each(function(item){ %>
<% var year = item.date.year(); %>
<% if (this_year != year || !this_year){ %>
<% if(this_year){ %>
</div></ul>
<% } %>
<div class="archive-itme"><div id="<%= year %>" class="archive-year"><%= year %></div>
<ul>
<% this_year = year; } %>
<li>
<time datetime="<%= item.date.toDate().toISOString() %>"><%= item.date.format("MM-DD") %></time>
<a href="<%- config.root %><%- item.path %>"><%= item.title %></a>
</li>
<% }); %>
</article>
<% } %>
</div>
</div>
</div>




35 changes: 35 additions & 0 deletions themes/zilan/layout/_partial/article.ejs
@@ -0,0 +1,35 @@
<article class="<%= item.layout %>">
<div class="post-content">
<header>
<%- partial('post/title') %>
<% if (item.layout != 'page'){ %>
<time datetime="<%= item.date.toDate().toISOString() %>"><%= item.date.format(config.date_format) %></time>
<% } %>
</header>
<div class="entry">
<% if (item.excerpt && index){ %>
<%- item.excerpt %>
<% } else { %>
<%- item.content %>
<% } %>
</div>
<% if (index){ %>
<% if (item.excerpt){ %>
<footer>
<div class="alignleft">
<a href="<%- config.root %><%- item.path %>#more" class="more-link"><%= theme.excerpt_link %></a>
</div>
<div class="clearfix"></div>
</footer>
<% } %>
<% } else { %>
<footer>
<div class="alignleft">
<%- partial('post/category') %>
<%- partial('post/tag') %>
</div>
<div class="clearfix"></div>
</footer>
<% } %>
</div>
</article>
11 changes: 11 additions & 0 deletions themes/zilan/layout/_partial/post/category.ejs
@@ -0,0 +1,11 @@
<% if (item.categories && item.categories.length){ %>
<%
var cats = [];
item.categories.forEach(function(cat){
cats.push('<a href="' + config.root + cat.path + '">' + cat.name + '</a>');
});
%>
<div class="categories">
<%- cats.join(', ') %>
</div>
<% } %>
11 changes: 11 additions & 0 deletions themes/zilan/layout/_partial/post/tag.ejs
@@ -0,0 +1,11 @@
<% if (item.tags && item.tags.length){ %>
<%
var tags = [];
item.tags.forEach(function(tag){
tags.push('<a href="' + config.root + tag.path + '">' + tag.name + '</a>');
});
%>
<div class="tags">
<%- tags.join(', ') %>
</div>
<% } %>
13 changes: 13 additions & 0 deletions themes/zilan/layout/_partial/post/title.ejs
@@ -0,0 +1,13 @@
<% if (item.link){ %>
<% if (item.title){ %>
<h1 class="title"><a href="<%- item.link %>" target="_blank"><%= item.title %></a></h1>
<% } else { %>
<h1 class="title"><a href="<%- item.link %>" target="_blank"><%= item.link %></a></h1>
<% } %>
<% } else { %>
<% if (index){ %>
<h1 class="title"><a href="<%- config.root %><%- item.path %>"><%= item.title %></a></h1>
<% } else { %>
<h1 class="title"><%= item.title %></h1>
<% } %>
<% } %>
54 changes: 6 additions & 48 deletions themes/zilan/layout/categories.ejs
@@ -1,53 +1,11 @@
---
layout: page
layout: layout
---

<!-- Main Content -->
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<!-- 归档列表 -->

<%
var years = {};
site.posts.sort('date').reverse().forEach(function(post){
var year = post.date.year()
if(years[year]===undefined){
years[year] = [];
}
years[year].push(post);
});
%>

<!-- 归档列表 -->

<% Object.keys(years).reverse().forEach(function(year){ %>
<div class="one-tag-list">
<span class="fa fa-calendar-times-o listing-seperator" id="<%= year %>">
<span class="tag-text"><%= year %></span>
</span>
<ul>
<% years[year].map(function(post){ %>
<!-- <li class="listing-item">
<time datetime="{{ post.date | date:"%Y-%m-%d" }}">{{ post.date | date:"%Y-%m-%d" }}</time>
<a href="{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a>
</li> -->
<li >
<%= post.date.format('MM-DD') %>
<i class="fa fa-angle-double-right" aria-hidden="true"></i>
<a href="<%- config.root %><%- post.path %>" style="color: #0085a1">
<span>
<%- post.title || "Untitled" %>
</span>
</a>
<!-- <p class="post-meta">{{ post.date | date:"%Y-%m-%d" }}</p> -->
</li>
<% }) %>
</ul>
</div>
<% }) %>


</div>
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1 categoriesPage">
<!-- categories list -->
<%- partial('_widget/' + 'category') %>
</div>
</div>
</div>
4 changes: 4 additions & 0 deletions themes/zilan/layout/category.ejs
@@ -0,0 +1,4 @@
---
layout: page
---
<%- partial('_partial/archive', {pagination: config.category}) %>

0 comments on commit 5005553

Please sign in to comment.