Skip to content

Commit

Permalink
[_partial/archive.ejs]├── archive.ejs //文章归档,包括单个分类与单个标签,调用 _partial/…
Browse files Browse the repository at this point in the history
…archive.ejs

├── categories.ejs  //显示所有分类的布局,
├── category.ejs  //单个分类显示的布局,调用 _partial/archive.ejs
├── tags.ejs  //显示所有显示的布局,调用 _partial/archive.ejs, 调用_partial/tags.ejs
  • Loading branch information
CatherineLiyuankun committed Feb 15, 2019
1 parent 5005553 commit 2183339
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 132 deletions.
83 changes: 42 additions & 41 deletions themes/zilan/layout/_partial/archive.ejs
@@ -1,44 +1,45 @@
<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 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 (type == 'tags'){ %>
<%- partial('tags') %>
<% } else { %>
<% var this_year; %>
<article class="archive">
<% site.posts.each(function(item){ %>
<% var year = item.date.year(); %>
<% if (this_year != year || !this_year){ %>
<% if(this_year){ %>
</div></ul>
<% } %>
<div class="archive-time">
<span id="<%= year %>" class="archive-year fa fa-calendar-times-o listing-seperator">
<%= year %></span>
<ul>
<% this_year = year; } %>
<li>
<time datetime="<%= item.date.toDate().toISOString() %>">
<%= item.date.format("MM-DD") %>
</time>
<i class="fa fa-angle-double-right" aria-hidden="true"></i>
<a href="<%- config.root %><%- item.path %>">
<%= item.title %></a>
</li>
<% }); %>
</article>
<% } %>
</div>
</div>
</div>
</div>




37 changes: 37 additions & 0 deletions themes/zilan/layout/_partial/tags.ejs
@@ -0,0 +1,37 @@
<!-- 标签云 -->
<div id='tag_cloud' class="tags">
<% site.tags.map(function(tag){ %>
<a href="#<%= tag.name %>" title="<%= tag.name %>" rel="<%= tag.length %>"><%= tag.name %></a>
<% }) %>
</div>

<!-- 标签列表 -->

<% site.tags.map(function(tag){ %>
<div class="one-tag-list">
<span class="fa fa-tag listing-seperator" id="<%= tag.name %>">
<span class="tag-text"><%= tag.name %></span>
</span>
<% tag.posts.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> -->
<div class="post-preview">
<a href="<%- config.root %><%- post.path %>">
<h2 class="post-title">
<%- post.title || "Untitled" %>
</h2>
<% if (post.subtitle && post.subtitle.length) { %>
<h3 class="post-subtitle">
<%- post.subtitle %>
</h3>
<% } %>
</a>
<!-- <p class="post-meta">{{ post.date | date:"%Y-%m-%d" }}</p> -->
</div>
<hr>
<% }) %>
</div>
<% }) %>

47 changes: 1 addition & 46 deletions themes/zilan/layout/archive.ejs
Expand Up @@ -2,49 +2,4 @@
layout: page
---

<!-- Main Content -->
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<!-- archives -->
<%
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>
</div>
<%- partial('_partial/archive', {type: 'archive'}) %>
3 changes: 2 additions & 1 deletion themes/zilan/layout/category.ejs
@@ -1,4 +1,5 @@
---
layout: page
---
<%- partial('_partial/archive', {pagination: config.category}) %>
<%- partial('_partial/archive', {type: 'category'}) %>

45 changes: 1 addition & 44 deletions themes/zilan/layout/tags.ejs
@@ -1,48 +1,5 @@
---
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">
<!-- 标签云 -->
<div id='tag_cloud' class="tags">
<% site.tags.map(function(tag){ %>
<a href="#<%= tag.name %>" title="<%= tag.name %>" rel="<%= tag.length %>"><%= tag.name %></a>
<% }) %>
</div>
<%- partial('_partial/archive', {type: 'tags'}) %>

<!-- 标签列表 -->

<% site.tags.map(function(tag){ %>
<div class="one-tag-list">
<span class="fa fa-tag listing-seperator" id="<%= tag.name %>">
<span class="tag-text"><%= tag.name %></span>
</span>
<% tag.posts.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> -->
<div class="post-preview">
<a href="<%- config.root %><%- post.path %>">
<h2 class="post-title">
<%- post.title || "Untitled" %>
</h2>
<% if (post.subtitle && post.subtitle.length) { %>
<h3 class="post-subtitle">
<%- post.subtitle %>
</h3>
<% } %>
</a>
<!-- <p class="post-meta">{{ post.date | date:"%Y-%m-%d" }}</p> -->
</div>
<hr>
<% }) %>
</div>
<% }) %>


</div>
</div>
</div>

0 comments on commit 2183339

Please sign in to comment.