Skip to content

Commit 00c70a4

Browse files
committed
tags implemenation
1 parent 8ee4f77 commit 00c70a4

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

_data/categories.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- slug: nosql
2+
name: NoSQL
3+
color: '#3498db'
4+
5+
- slug: programming
6+
name: Programming
7+
color: '#1abc9c'

_data/tags.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- slug: maizi
2+
name: Maizi
3+
4+
- slug: mongodb
5+
name: MongoDB

_layouts/blog_by_tag.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
layout: default
3+
---
4+
5+
<header id="post-header">
6+
<h1 id="post-title">{{ page.tag }}</h1>
7+
<h4 id="post-subtitle">Articles by tag</h4>
8+
</header>
9+
10+
<div id="post-content">
11+
{% if site.tags[page.tag] %}
12+
{% for post in site.tags[page.tag] %}
13+
{% capture post_year %}{{ post.date | date: '%Y' }}{% endcapture %}
14+
{% if forloop.first %}
15+
<h3>{{ post_year }}</h3><div class="list-group">
16+
{% endif %}
17+
18+
{% if forloop.first == false %}
19+
{% assign previous_index = forloop.index0 | minus: 1 %}
20+
{% capture previous_post_year %}{{ site.tags[page.tag][previous_index].date | date: '%Y' }}{% endcapture %}
21+
{% if post_year != previous_post_year %}
22+
</div><h3>{{ post_year }}</h3><div class="list-group">
23+
{% endif %}
24+
{% endif %}
25+
26+
<a href="{{ post.url }}/" class="list-group-item">
27+
<h4 class="list-group-item-heading">{{ post.title }}</h4>
28+
</a>
29+
30+
{% if forloop.last %}
31+
</div>
32+
{% endif %}
33+
{% endfor %}
34+
{% else %}
35+
<p>There are no posts for this tag.</p>
36+
{% endif %}
37+
</div>

_posts/2015-1-1-MongoDB-Notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
layout: post
33
title: MongoDB最佳实践笔记
44
published: true
5-
category: MongoDB
6-
tags: [MongoDB, Maizi]
5+
category: nosql
6+
tags: [mongodb, maizi]
77
---
88

99
主要还得看官网

0 commit comments

Comments
 (0)