在主页上显示最近的博客活动



使用Lektor,尝试确定如何在主登陆(根(页面上按发布日期列出最近的三个博客。我觉得我应该使用宏,但我不明白如何将博客传递给页面模板,或者这是否是流块的示例?我在页面上添加了如下所示的部分.ini:

[children]
model = blog-post
order_by = -pub_date, title

但似乎无法在模板中循环遍历它们(没有抛出错误但不迭代(。很迷茫,但仍然消耗文档。

我最终直接在布局模板中使用了 site.query 类功能(基于博客快速入门(。

{% for blogpost in site.query('/blog').order_by('pub_date').limit(3) %}
<div class="post col-md-4">
<div class="post-details">
<div class="post-meta d-flex justify-content-between">
<div class="date">{{ blogpost.pub_date }}</div>
</div><a href="post.html"> <!-- fix this one shortly -->
<h3 class="h4">{{ blogpost.title }}</h3></a>
<p class="text-muted">{{ blogpost.teaser }}</p>
</div>
</div>
{% endfor %}

最新更新