-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for tags and related posts
- Loading branch information
Showing
8 changed files
with
196 additions
and
5 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 @@ | ||
<div style="float:right;"><a href="{{ site.github.url }}/">< Back to home</a></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,32 @@ | ||
{% comment %} | ||
Borrowed from https://codinfox.github.io/dev/2015/03/06/use-tags-and-categories-in-your-jekyll-based-github-pages/ | ||
{% endcomment %} | ||
|
||
{% comment %} | ||
======================= | ||
The following part extracts all the tags from your posts and sort tags, so that you do not need to manually collect your tags to a place. | ||
======================= | ||
{% endcomment %} | ||
{% assign rawtags = "" %} | ||
{% for post in site.posts %} | ||
{% assign ttags = post.tags | join:'|' | append:'|' %} | ||
{% assign rawtags = rawtags | append:ttags %} | ||
{% endfor %} | ||
{% assign rawtags = rawtags | split:'|' | sort %} | ||
|
||
{% comment %} | ||
======================= | ||
The following part removes dulpicated tags and invalid tags like blank tag. | ||
======================= | ||
{% endcomment %} | ||
{% assign tags = "" %} | ||
{% for tag in rawtags %} | ||
{% if tag != "" %} | ||
{% if tags == "" %} | ||
{% assign tags = tag | split:'|' %} | ||
{% endif %} | ||
{% unless tags contains tag %} | ||
{% assign tags = tags | join:'|' | append:'|' | append:tag | split:'|' %} | ||
{% endunless %} | ||
{% endif %} | ||
{% endfor %} |
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
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,32 @@ | ||
--- | ||
layout: default | ||
--- | ||
|
||
<div class="post"> | ||
{% include back_to_home.html %} | ||
<h1 class="page-heading">Posts by Tag</h1> | ||
|
||
<ul class="post-list"> | ||
|
||
{% include find_tags.html %} | ||
|
||
{% for tag in tags %} | ||
<h2 id="{{ tag | slugify }}">{{ tag }}</h2> | ||
<ul> | ||
{% for post in site.posts %} | ||
{% if post.tags contains tag %} | ||
<li> | ||
<h3> | ||
<a href="{{ post.url }}"> | ||
{{ post.title }} | ||
<br><small>{{ post.date | date_to_string }}—{{ post.author }}</small> | ||
</a> | ||
</h3> | ||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
{% endfor %} | ||
</ul> | ||
|
||
</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
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,70 @@ | ||
.related { | ||
max-width: -webkit-calc(980px - (#{$spacing-unit}*7)); | ||
max-width: calc(980px - (#{$spacing-unit}*7)); | ||
h3 { | ||
margin: #{$spacing-unit} 0 #{$spacing-unit} calc(#{$spacing-unit}*4); | ||
} | ||
} | ||
|
||
.related-flex { | ||
margin: 0 calc(-#{$spacing-unit} / 2) 0 calc(-#{$spacing-unit} / 2); | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
} | ||
.related-post { | ||
background: $at-white; | ||
flex-basis: -webkit-calc(((#{$page-width} - #{$spacing-unit}*9)/2) - 8*#{$spacing-unit}); | ||
flex-basis: calc(((#{$page-width} - #{$spacing-unit}*9)/2) - 8*#{$spacing-unit}); | ||
flex-grow: 1; | ||
display: inline-block; | ||
|
||
margin: -webkit-calc(#{$spacing-unit} / 2); | ||
margin: calc(#{$spacing-unit} / 2); | ||
|
||
padding: -webkit-calc(#{$spacing-unit}*4) -webkit-calc(#{$spacing-unit}*4) -webkit-calc(#{$spacing-unit}*2) -webkit-calc(#{$spacing-unit}*4); | ||
padding: calc(#{$spacing-unit}*4) calc(#{$spacing-unit}*4) calc(#{$spacing-unit}*2) calc(#{$spacing-unit}*4); | ||
ul { | ||
margin: 0; | ||
li { | ||
display: inline; | ||
} | ||
} | ||
} | ||
.tag { | ||
margin-right: #{$spacing-unit}; | ||
} | ||
|
||
/* | ||
.related { | ||
max-width: -webkit-calc(980px - (#{$spacing-unit}*7)); | ||
max-width: calc(980px - (#{$spacing-unit}*7)); | ||
margin-top: #{$spacing-unit}; | ||
} | ||
.related-flex { | ||
margin: calc(-#{$spacing-unit} / 2); | ||
} | ||
.related-post { | ||
background: $at-white; | ||
max-width: -webkit-calc(((#{$page-width} - #{$spacing-unit}*9)/2) - 2*#{$spacing-unit}); | ||
max-width: calc(((#{$page-width} - #{$spacing-unit}*9)/2) - 2*#{$spacing-unit}); | ||
margin: -webkit-calc(#{$spacing-unit} / 2); | ||
margin: calc(#{$spacing-unit} / 2); | ||
padding: #{$spacing-unit}; | ||
float: left; | ||
ul { | ||
margin: 0; | ||
li { | ||
display: inline; | ||
} | ||
} | ||
} | ||
.tag { | ||
margin-right: #{$spacing-unit}; | ||
} | ||
*/ |
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
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,3 @@ | ||
--- | ||
layout: tags | ||
--- |