hexojs / hexo-generator-index

Index generator plugin for Hexo.
MIT License
51 stars 44 forks source link

Feature Request: Hide posts from the index #88

Open zhang-stephen opened 1 year ago

zhang-stephen commented 1 year ago

Is it possible to add an option, e.g. hidden: true, into front matter, and to remove this post from the index page?

SukkaW commented 1 year ago

@zhang-stephen

Currently, the hexo-generator-index doesn't have such an option, but hexo themes can implement this very easily! Here is an example with .ejs:

<!-- Post List -->
<% page.posts.each((post) => { %>
  <!-- Post Entry -->
  <%- partial('_partial/post-entry', { post }) %>
<% }); %>
<!-- Post List -->
<% page.posts.each((post) => { %>
  <!-- Post Entry -->
+ <% if (post.hidden !== true) { %>
  <%- partial('_partial/post-entry', { post }) %>
+ <% } %>
<% }); %>