Skip to content
Permalink
Browse files

添加文章置顶功能

配置方法为: 在需要置顶的文章的 Front-matter 内设置 top 变量为 true.
  • Loading branch information
sqrtthree
sqrtthree committed Jun 17, 2015
1 parent d305829 commit 9a5c162d3bab7a9713a424ec46608ce6fdeded05
Showing with 32 additions and 3 deletions.
  1. +6 −1 layout/_partial/archive.ejs
  2. +6 −1 layout/_partial/article.ejs
  3. +20 −1 source/css/_partial/tagcloud.styl
@@ -1,4 +1,9 @@
<% if (pagination == 2){ %>
<% page.posts.data = page.posts.data.sort(function(prev, next) { %>
<% if (next.top && !prev.top) { %>
<% return true; %>
<% } %>
<% }); %>
<% page.posts.each(function(post){ %>
<%- partial('article', {post: post, index: true}) %>
<% }) %>
@@ -30,4 +35,4 @@
<% if (page.posts.length){ %>
</div></section>
<% } %>
<% } %>
<% } %>
@@ -29,6 +29,11 @@
</div>
<% if (index){ %>
<div class="article-info article-info-index">
<%if(post.top){%>
<div class="article-pop-out tagcloud">
<a class="">置顶</a>
</div>
<% } %>
<%- partial('post/tag') %>
<%- partial('post/category') %>
<% if (post.excerpt && index){ %>
@@ -73,4 +78,4 @@
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</section>
<% } %>
<% } %>
@@ -341,4 +341,23 @@
margin-top: 9px;
float: left;
}
}
}
.article-pop-out {
float: left;
&:before{
float: left;
color: #999;
content: "\f08d";
font: 16px FontAwesome;
float: left;
margin-right: 10px;
margin-top: 9px;
}
&:after{
float: left;
content: "";
margin-right: 20px;
margin-top: 9px;
float: left;
}
}

0 comments on commit 9a5c162

Please sign in to comment.
You can’t perform that action at this time.