Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[categories] page and category page work
- Loading branch information
1 parent
86d52a8
commit 5005553
Showing
7 changed files
with
124 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
<% } %> | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
layout: page | ||
--- | ||
<%- partial('_partial/archive', {pagination: config.category}) %> |