2

Using Lektor, trying to determine how to list the most recent three blogs by published date on the main landing (root) page. I'm feeling like I should be using a macro, but I don't understand how to pass the Blogs to the page template, or if this is an example of a flowblock? I've added a section like the following to the page.ini:

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

but can't seem to loop through them in the template (no error is thrown but doesn't iterate). Quite lost, but still consuming the documentation.

AMG
  • 1,606
  • 1
  • 14
  • 25

1 Answers1

2

I ended up using the site.query class functionality directly in the layout template (based on the Blog quickstart).

{% 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 %}
AMG
  • 1,606
  • 1
  • 14
  • 25