probberechts / hexo-theme-cactus

:cactus: A responsive, clean and simple theme for Hexo.
https://probberechts.github.io/hexo-theme-cactus/
MIT License
3.15k stars 783 forks source link

Latest updates #261

Closed h0ek closed 3 years ago

h0ek commented 3 years ago

Is it possible somehow to display similar section to writing (I call it Latest post) on the main page:

<section id="writing">
  <span class="h1"><a href="<%- url_for("archives") %>"><%= __('index.articles') %></a></span>
  <% if (theme.tags_overview && site.tags.length) { %>
  <span class="h2"><%= __('index.topics') %></span>
  <span class="widget tagcloud">
    <%- tagcloud(theme.tags_overview) %>
  </span>
  <span class="h2"><%= __('index.most_recent') %></span>
  <% } %>
  <ul class="post-list">
    <% var field_sort = theme.posts_overview.sort_updated ? 'updated' : 'date' %>
    <% if (theme.posts_overview.show_all_posts) { %>
      <% var show_posts = page.posts.sort(field_sort, 'desc') %>
    <% } else { %>
      <% var show_posts = site.posts.sort(field_sort, 'desc').limit(theme.posts_overview.post_count || 5) %>
    <% } %>
    <% show_posts.each(function(post, i){ %>
      <li class="post-item">
        <%- partial('_partial/post/date', { post: post, class_name: 'meta' }) %>
        <span><%- partial('_partial/post/title', { post: post, index: true, class_name: '' }) %></span>
      </li>
    <% }); %>
  </ul>
  <% if (theme.posts_overview.show_all_posts) { %>
    <%- partial('_partial/pagination') %>
  <% } %>
</section>

Next to the standard one but with "latest updates"?

I know I can sort it by update time, but I would like to have two columns, one column like it is now

posts_overview:
  show_all_posts: false
  post_count: 5
  sort_updated: false

and second:

posts_overview:
  show_all_posts: false
  post_count: 5
  sort_updated: true

I tried to modify the code but always mess up something :(

probberechts commented 3 years ago

Sorry, but I am not interested in implementing this. If you want this custom functionality you will have to implement it by yourself.