Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
feat(layout): complete categories and tags page
Browse files Browse the repository at this point in the history
  • Loading branch information
ppoffice committed Apr 18, 2018
1 parent 0ca2950 commit 259592d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 23 deletions.
2 changes: 2 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ common:
archives: 'Archives'
category: 'Category'
tag: 'Tag'
categories: 'Categories'
tags: 'Tags'
nav:
next: 'Next'
prev: 'Prev'
Expand Down
2 changes: 2 additions & 0 deletions languages/zh-cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ common:
archives: '归档'
category: '分类'
tag: '标签'
categories: '分类'
tags: '标签'
nav:
next: '下一页'
prev: '上一页'
Expand Down
21 changes: 18 additions & 3 deletions layout/categories.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<% page._categories.forEach(category => {%>
<%= category.name %>
<% }) %>
<section class="section section-heading">
<div class="container">
<div class="content">
<h5><i class="far fa-folder"></i><%= __('common.categories') %></h5>
</div>
</div>
</section>
<section class="section">
<div class="container">
<div class="columns is-variable is-1 is-multiline is-mobile">
<% (page._categories || page.categories).forEach(category => {%>
<span class="column is-narrow">
<a class="tag is-light article-tag" href="<%= url_for(category.path) %>"><%= category.name %>&nbsp;(<%= category.posts.length%>)</a>
</span>
<% }) %>
</div>
</div>
</section>
4 changes: 2 additions & 2 deletions layout/common/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
<% } %>
</div>
<% if (!index && post.tags && post.tags.length){ %>
<div class="columns is-multiline is-mobile article-tags">
<div class="columns is-variable is-1 is-multiline is-mobile">
<% (post._tags || post.tags).forEach(tag => { %>
<span class="column is-narrow"><a href="<%- url_for(tag.path) %>">#<%= tag.name %></a></span>
<span class="column is-narrow"><a class="tag is-light article-tag" href="<%- url_for(tag.path) %>">#<%= tag.name %></a></span>
<% }) %>
</div>
<% } %>
Expand Down
21 changes: 18 additions & 3 deletions layout/tags.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<% page._tags.forEach(tag => {%>
<%= tag.name %>
<% }) %>
<section class="section section-heading">
<div class="container">
<div class="content">
<h5>#<%= __('common.tags') %></h5>
</div>
</div>
</section>
<section class="section">
<div class="container">
<div class="columns is-variable is-1 is-multiline is-mobile">
<% (page._tags || page.tags).forEach(tag => {%>
<span class="column is-narrow">
<a class="tag is-light article-tag" href="<%= url_for(tag.path) %>">#<%= tag.name %>&nbsp;(<%= tag.posts.length%>)</a>
</span>
<% }) %>
</div>
</div>
</section>
6 changes: 4 additions & 2 deletions scripts/10_i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ hexo.extend.generator.register('categories', withLanguage(function(languages, lo
return null;
}
return Object.assign({}, category, {
posts: posts
posts: posts,
path: i === 0 ? category.path : pathJoin(language, category.path)
});
}).filter(category => category !== null);
return {
Expand All @@ -257,7 +258,8 @@ hexo.extend.generator.register('tags', withLanguage(function(languages, locals)
return null;
}
return Object.assign({}, tag, {
posts: posts
posts: posts,
path: i === 0 ? tag.path : pathJoin(language, tag.path)
});
}).filter(category => category !== null);
return {
Expand Down
19 changes: 6 additions & 13 deletions source/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ body, button, input, select, textarea {
font-family: $family-serif;
}


a.tag.article-tag {
font-size: 0.9rem;
text-decoration: none;
}

@media screen and (min-width: 1024px) {
.container {
max-width: 800px;
Expand Down Expand Up @@ -93,19 +99,6 @@ body, button, input, select, textarea {
}
}

.article-tags {
.column:not(:first-child) {
margin-left: -.75rem;
}

span a {
color: inherit;
background: #f2f2f2;
padding: 0.2rem 0.5rem;
border-radius: 3px;
}
}

.article-nav {
a {
color: darkgray;
Expand Down

0 comments on commit 259592d

Please sign in to comment.