List New Articles Based on Page Update

Hi. I was trying to list articles by page update but haven’t been able to do it just yet. Currently I have the articles being listed by date published, here’s the code I have now:

<div>
    <% blog('articles').articles.sort_by(&:date).reverse.each do |article| %>
    <article>

    </article>
    <% end %>
</div>

I was hoping to use something similar to <%= File.mtime(current_page.source_file) %> I believe?

You can use File.mtime just fine. As an example it is used by XML-feed builder (/source/feed.xml.builder):

      xml.updated File.mtime(article.source_file).iso8601

I also use this construct in my custom helper which computes “Last update” string for portfolio photo-pages built from YML data, checking the modification date of source YML files and JPG files listed there to compute the “Last update” value.

1 Like

@komor72 thats Brilliant! Thank you so much!!!