6 Collection
Hugo Soucy edited this page 3 months ago

Page collection

Open the lua file of the page where you want to display a collection. Add the collection property with a table as value. In that table, you can put one or more relative paths to repositories or pages:

return {
  date = "2017-03-16",
  datetime = "10:00:00",
  template = "default-index",
  title = "Georges Méliès: french illusionist, actor and film director ",
  collection = { 'filmography/', 'books/', 'about.md' },
}

Also you can add some lua script if you want dynamic values such as a date:

collection = { 'blog/'..os.date('%Y')..'/' },

Here it returns something like this blog/2022/.

Then in the template file, add the loop to display the list of pages in the collection:

<% if collection then %>
  <ol>
    <% for _, child in ipairs(collection) do %>
      <li>
        <a href="<%= child.rellink -%>"><%= child.title -%></a> &mdash;
        <time datetime="<%= child.date -%>T<%= child.datetime -%>"><%= child.date -%></time>
      </li>
    <% end %>
  </ol>
<% end %>