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">
|
||||
<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">
|
||||
|
|
|
@ -13,9 +13,12 @@ def category_find(categories, name):
|
|||
|
||||
|
||||
def limit(line, length):
|
||||
if len(line) <= length:
|
||||
return line
|
||||
return " ".join(line.split(" ")[: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):
|
||||
|
|
Reference in a new issue