使用 Lektor,尝试确定如何在主登录(根)页面上按发布日期列出最近的三个博客。我觉得我应该使用宏,但我不明白如何将博客传递给页面模板,或者这是一个流程块的示例?我在 page.ini 中添加了如下部分:
[children]
model = blog-post
order_by = -pub_date, title
但似乎无法在模板中循环它们(不会引发错误但不会迭代)。很迷茫,但仍在消耗文档。
使用 Lektor,尝试确定如何在主登录(根)页面上按发布日期列出最近的三个博客。我觉得我应该使用宏,但我不明白如何将博客传递给页面模板,或者这是一个流程块的示例?我在 page.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 %}