Skip to content

Commit

Permalink
added archive page
Browse files Browse the repository at this point in the history
  • Loading branch information
artchen committed Sep 25, 2016
1 parent 22f1cd7 commit e6ad77a
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 4 deletions.
6 changes: 3 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ navigation:
- name: About
slug: about
url: /about
- name: Works
slug: works
url: /works
- name: Archives
slug: archives
url: /archives

# Search
search:
Expand Down
12 changes: 12 additions & 0 deletions layout/_partial/archive.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
</section>
<% } %>

<% if (is_archive()) { %>
<section class="page-header archive">
<h1>- <span><%= page.year %><%= page.month ? '.' + page.month : '' %></span> -</h1>
</section>
<% } %>

<% if (is_category()) { %>
<section class="page-header category">
<h1>- <span><%= page.category %></span> -</h1>
</section>
<% } %>

<section class="post-list">
<% page.posts.each(function(post){ %>
<%- partial('post', {post: post}) %>
Expand Down
51 changes: 51 additions & 0 deletions layout/archive.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<% if (page.year || page.month) { %>
<%- partial('_partial/archive') %>
<% } else { %>
<article id="archive-page"
class="post article white-box">
<h2 class="title">
<a href="/archives">
Archives
</a>
</h2>
<section class="archive">
<%
var year = -1, postid = -1;
page.posts.each(function(post) {
post.year = date(post.date, 'YYYY');
if (post.year && post.year !== year) {
year = post.year;
%>
<h3 class="archive-item archive-year">
<a id="archive-year-<%= year %>" href="/archives/<%= year %>/">
<%= year %>
</a>
</h3>
<% } %>
<div class="archive-item archive-post">
<a href="<%= url_for(post.path) %>">
<time><%= date(post.date, 'MM-DD') %></time>
<span class="title"><%= post.title %></span>
</a>
</div>
<% }); %>
</section>
</article>
<% if (page.total > 1) { %>
<nav id="page-nav">
<% if (page.prev != 0) { %>
<a class="prev" rel="prev" href="<%= url_for(page.prev_link) %>">
<span class="icon icon-chevron-left"></span>
<span class="text">Previous</span>
</a>
<% } %>
<% if (page.next != 0) { %>
<a class="next" rel="next" href="<%= url_for(page.next_link) %>">
<span class="text">Next</span>
<span class="icon icon-chevron-right"></span>
</a>
<% } %>
</nav>
<% } %>
<% } %>
1 change: 1 addition & 0 deletions layout/category.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%- partial('_partial/archive') %>
1 change: 1 addition & 0 deletions layout/tag.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%- partial('_partial/archive') %>
38 changes: 38 additions & 0 deletions source/less/_archive.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#archive-page {

.archive {
position: relative;
padding: 20px;

.archive-item {
position: relative;

a {
display: inline-block;
padding: 3px 15px;
border-left: 3px solid transparent;
background: transparent;
transition: all ease 0.24s;

&:hover {
border-left-color: lighten(@accent-color,10%);
background: lighten(@background-color,2%);
}
}
}
.archive-year {
font-size: 16px;
margin: 10px 0px;
}
.archive-post {
time {
font-size: 12px;
padding-right: 10px;
}
.title {
font-size: 14px;
color: @accent-color;
}
}
}
}
3 changes: 2 additions & 1 deletion source/less/_main.less
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
}
}
&:last-child,
&.single {
&.single,
&#archive-page {
margin-bottom: 0px;
}
&.author-profile {
Expand Down
1 change: 1 addition & 0 deletions source/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

@import "less/_header.less";
@import "less/_main.less";
@import "less/_archive.less";
@import "less/_content.less";
@import "less/_pagination.less";
@import "less/_search.less";
Expand Down

0 comments on commit e6ad77a

Please sign in to comment.