Update related posts

This commit is contained in:
agusmakmun
2016-04-19 16:22:55 +07:00
parent 7ea1661747
commit f3bca594ad
6 changed files with 34 additions and 5 deletions

View File

@@ -7,3 +7,32 @@ layout: default
<div class="content"> <div class="content">
<div class="post">{{ content }}</div> <div class="post">{{ content }}</div>
</div> </div>
{% assign hasSimilar = '' %}
{% for post in site.posts %}
{% assign postHasSimilar = false %}
{% for tag in post.categories %}
{% for thisTag in page.categories %}
{% if postHasSimilar == false and hasSimilar.size < 6 and post != page and tag == thisTag %}
{% if hasSimilar.size == 0 %}
<div class="panel-body">
<h4>Related Posts</h4>
<ul>
{% endif %}
<li class="relatedPost">
<a href="{{ site.url }}{{ post.url }}">{{ post.title }}
{% if post.categories %}
(Categories: {{ post.categories | join: ', ' }})
{% endif %}
</a>
</li>
{% capture hasSimilar %}{{ hasSimilar }}*{% endcapture %}
{% assign postHasSimilar = true %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% if hasSimilar.size > 0 %}
</ul>
</div>
{% endif %}

View File

@@ -2,7 +2,7 @@
layout: post layout: post
title: "Parsing JSON with Ruby" title: "Parsing JSON with Ruby"
date: 2013-12-23 00:18:23 +0700 date: 2013-12-23 00:18:23 +0700
categories: ruby categories: [ruby]
--- ---
Parsing JSON with Ruby is actually extremely easy. All you have to do is have the json gem installed (`gem install json`) and call the `JSON.parse` method on the JSON data to convert it to ruby hashes. If you look at this small program here, you can see how I have implemented parsing JSON in Ruby. Parsing JSON with Ruby is actually extremely easy. All you have to do is have the json gem installed (`gem install json`) and call the `JSON.parse` method on the JSON data to convert it to ruby hashes. If you look at this small program here, you can see how I have implemented parsing JSON in Ruby.

View File

@@ -2,7 +2,7 @@
layout: post layout: post
title: "Welcome to Simply Grey" title: "Welcome to Simply Grey"
date: 2013-12-23 00:18:23 +0700 date: 2013-12-23 00:18:23 +0700
categories: simplygrey categories: [simplygrey]
--- ---
SimplyGrey is a simple, easy to use theme for Jekyll that compromises of mainly grey colours. A lot of people enjoy the simplistic look of grey and also find it easier to read. SimplyGrey is a simple, easy to use theme for Jekyll that compromises of mainly grey colours. A lot of people enjoy the simplistic look of grey and also find it easier to read.

View File

@@ -2,7 +2,7 @@
layout: post layout: post
title: "Email BackEnd with SMTP Gmail" title: "Email BackEnd with SMTP Gmail"
date: 2016-04-19 02:28:15 +0700 date: 2016-04-19 02:28:15 +0700
categories: django categories: [python, django]
--- ---
Add this configurations in your `settings.py` Add this configurations in your `settings.py`

View File

@@ -2,7 +2,7 @@
layout: post layout: post
title: "Remove all files .pyc with recrusive method" title: "Remove all files .pyc with recrusive method"
date: 2016-04-19 14:39:34 +0700 date: 2016-04-19 14:39:34 +0700
categories: python bash categories: [python, bash]
--- ---
This method simple but important. Example in your project dir is like this: This method simple but important. Example in your project dir is like this:

View File

@@ -2,7 +2,7 @@
layout: post layout: post
title: "Welcome to Jekyll!" title: "Welcome to Jekyll!"
date: 2013-02-19 21:28:15 +0700 date: 2013-02-19 21:28:15 +0700
categories: jekyll update categories: [jekyll, update]
--- ---
Youll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated. Youll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.