Limit blog posts on index
This commit is contained in:
parent
a945dec3df
commit
5bc8f482e5
2 changed files with 8 additions and 6 deletions
|
@ -111,12 +111,11 @@
|
||||||
<hr class="light">
|
<hr class="light">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-10 col-sm-offset-1">
|
<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="row">
|
||||||
<div class="col-xs-12 text-left">
|
<div class="col-xs-12 text-left">
|
||||||
<p class="h3"><a href="{{ article.url }}">{{ article.title }}</a></p>
|
<p class="h3"><a href="{{ article.url }}">{{ article.title }}</a></p>
|
||||||
<h3>{{ article.title }}</h3>
|
<p>{{ article.summary|striptags|e }}</p>
|
||||||
<p>{{ article.summary|striptags|e|limit(30) }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr class="light">
|
<hr class="light">
|
||||||
|
|
|
@ -13,9 +13,12 @@ def category_find(categories, name):
|
||||||
|
|
||||||
|
|
||||||
def limit(line, length):
|
def limit(line, length):
|
||||||
if len(line) <= length:
|
if isinstance(line, str):
|
||||||
return line
|
if len(line) <= length:
|
||||||
return " ".join(line.split(" ")[:length]) + '...'
|
return line
|
||||||
|
return " ".join(line.split(" ")[:length]) + '...'
|
||||||
|
elif isinstance(line, list):
|
||||||
|
return line[:length]
|
||||||
|
|
||||||
|
|
||||||
def format_title(value):
|
def format_title(value):
|
||||||
|
|
Reference in a new issue