Skip to content

Commit

Permalink
add tags
Browse files Browse the repository at this point in the history
  • Loading branch information
fengrk committed Mar 1, 2020
1 parent 40d7b6a commit 6a329b1
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 1 deletion.
5 changes: 4 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ navs:

- href: /categories/
label: 分类


- href: /tags/
label: 标签

- href: /archives/
label: 归档

Expand Down
22 changes: 22 additions & 0 deletions _includes/sidebar-tags-nav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

<h3>Blog Tags</h3>
<div id="blog-tags">
<ul class="list-group">
{% assign sorted_tags = site.tags | sort %}
{% for tag in sorted_tags %}
<li class="list-group-item">
<a href="#{{ tag[0] }}">{{ tag | first }}</a>
<span class="badge">{{ tag[1].size }}</span>
</li>
{% endfor %}
</ul>
</div>

<script type="text/javascript">

$(document).ready(function(){
$("#blog-tags li").css('text-transform','capitalize')
});

</script>

27 changes: 27 additions & 0 deletions _includes/sidebar-tags-nav_bak.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

<h3>Blog Tags</h3>
<div id="blog-tags">
<ul class="list-group">
{% capture tags %}
{% for tag in site.tags %}
{{ tag[1].size | plus: 1000 }}#{{ tag[0] }}#{{ tag[1].size }}
{% endfor %}
{% endcapture %}
{% assign sorted_tags = tags | split:' ' | sort %}
{% for tag in sorted_tags %}{% assign tag_items = tag | split: '#' %}
<li class="list-group-item">
<a href="#{{ tag_items[1] }}">{{ tag_items[1] | first }}</a>
<span class="badge">{{ tag_items[2] }}</span>
</li>
{% endfor %}
</ul>
</div>

<script type="text/javascript">

$(document).ready(function(){
$("#blog-tags li").css('text-transform','capitalize')
});

</script>

1 change: 1 addition & 0 deletions _layouts/categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h1 class="collection-header">{{ page.title }}</h1>
{% include sidebar-search.html %}
{% include sidebar-qrcode.html %}
{% include sidebar-categories-nav.html %}
{% include sidebar-tags-nav.html %}
</div>
</div>
</section>
Expand Down
36 changes: 36 additions & 0 deletions _layouts/tags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
layout: default
---
<section class="collection-head small geopattern" data-pattern-id="{{ page.title | truncate: 15, ''}}">
<div class="container">
<div class="columns">
<div class="column three-fourths">
<div class="collection-title">
<h1 class="collection-header">{{ page.title }}</h1>
</div>
</div>
</div>
</div>
</section>
<!-- / .banner -->
<section class="container content">
<div class="columns">
<div class="column three-fourths" >
<article class="article-content markdown-body">
{{ content }}
</article>
<div class="share">
{% include sns-share.html %}
</div>
<div class="comment">
{% include comments.html %}
</div>
</div>
<div class="column one-fourth">
{% include sidebar-search.html %}
{% include sidebar-qrcode.html %}
{% include sidebar-categories-nav.html %}
</div>
</div>
</section>
<!-- /section.content -->
25 changes: 25 additions & 0 deletions pages/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: tags
title: Tags
description: 标签
keywords: 标签
comments: false
menu: 标签
permalink: /tags/
---

<section class="container posts-content">
{% assign sorted_tags = site.tags | sort %}
{% for tag in sorted_tags %}
<h3>{{ tag | first }}</h3>
<ol class="posts-list" id="{{ tag[0] }}">
{% for post in tag.last %}
<li class="posts-list-item">
<span class="posts-list-meta">{{ post.date | date:"%Y-%m-%d" }}</span>
<a class="posts-list-name" href="{{ site.url }}{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a>
</li>
{% endfor %}
</ol>
{% endfor %}
</section>
<!-- /section.content -->

0 comments on commit 6a329b1

Please sign in to comment.