1
Fork 0

Limit blog posts on index

This commit is contained in:
Jake Howard 2016-07-04 23:17:15 +01:00
parent a945dec3df
commit 5bc8f482e5
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 8 additions and 6 deletions

View file

@ -111,12 +111,11 @@
<hr class="light">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
{% for article in categories|category_find("blog") %}
{% for article in categories|category_find("blog")|limit(4) %}
<div class="row">
<div class="col-xs-12 text-left">
<p class="h3"><a href="{{ article.url }}">{{ article.title }}</a></p>
<h3>{{ article.title }}</h3>
<p>{{ article.summary|striptags|e|limit(30) }}</p>
<p>{{ article.summary|striptags|e }}</p>
</div>
</div>
<hr class="light">

View file

@ -13,9 +13,12 @@ def category_find(categories, name):
def limit(line, length):
if isinstance(line, str):
if len(line) <= length:
return line
return " ".join(line.split(" ")[:length]) + '...'
elif isinstance(line, list):
return line[:length]
def format_title(value):