Browse Source

Fix sorting article by update date

Fix #149
pull/166/head
Pieter Robberechts 8 months ago
parent
commit
25533f517d
3 changed files with 4 additions and 2 deletions
  1. 2
    0
      _config.yml
  2. 1
    1
      layout/_partial/post/date.ejs
  3. 1
    1
      layout/archive.ejs

+ 2
- 0
_config.yml View File

@@ -48,6 +48,8 @@ posts_overview:
# Customize the archive view.
# Options:
# - sort_updated: sort posts by last modification date instead of creation date.
# Note: this does not work together with pagination, since the pagination
# plugin will sort pages by date of creation.
archive:
sort_updated: false


+ 1
- 1
layout/_partial/post/date.ejs View File

@@ -6,7 +6,7 @@
(Updated: <time datetime="<%= date_xml(post.updated) %>" itemprop="dateModified"><%= date(post.updated, config.date_format) %></time>)
<% } %>
<% } else { %>
<% if (theme.posts_overview.sort_updated) { %>
<% if (is_home() && theme.posts_overview.sort_updated || is_archive() && theme.archive.sort_updated ) { %>
<time datetime="<%= date_xml(post.updated) %>" itemprop="dateModified"><%= date(post.updated, config.date_format) %></time>
<% } else { %>
<time datetime="<%= date_xml(post.date) %>" itemprop="datePublished"><%= date(post.date, config.date_format) %></time>

+ 1
- 1
layout/archive.ejs View File

@@ -4,7 +4,7 @@
<% var change = false %>
<% var field_sort = theme.archive.sort_updated ? 'updated' : 'date' %>
<% page.posts.sort(field_sort, 'desc').each(function(post) { %>
<% var itemYear = date(post.date, 'YYYY') - 0 %>
<% var itemYear = date(post[field_sort], 'YYYY') - 0 %>
<% change = year !== itemYear %>
<% year = change ? itemYear : year %>
<% if (change) { %>

Loading…
Cancel
Save