How To List HexoJS Posts By Updated Date #4920
Answered
by
stevenjoezhang
dimaslanjaka
asked this question in
Question / Answer
-
ENVhexo 6.0.0 Behaviouri have code to iterate posts <% page.posts.each(function(post, i) { %>
<% var year = post.date.year(); %>
<!-- any element, example below with variable usage -->
This post year is <%= year %> and last updated at <%= post.updated.toString(); %>
<% }); %> Questions: how to order the
trying create helper function to order posts by updated date: // how to order the posts in this function?
function list_post_by_updated(posts) {
return posts;
}
/// usage <% list_post_by_updated(page.posts).each(function(post, i) { %>
hexo.extend.helper.register('list_post_by_updated', function (posts) {
return list_post_by_updated(posts);
}); |
Beta Was this translation helpful? Give feedback.
Answered by
stevenjoezhang
Mar 26, 2022
Replies: 1 comment 1 reply
-
In Hexo
the default value of |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dimaslanjaka
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Hexo
_config.yml
, setthe default value of
order_by
option is-date
, change it to-updated