blog/themes/fluid/layout/_partials/category-chains.ejs

20 lines
795 B
Plaintext
Raw Normal View History

2024-11-16 11:34:10 +08:00
<% function render_category_chain(cat) { %>
<a href="<%= url_for(cat.path) %>" class="category-chain-item"><%= cat.name.trim() %></a>
<% var nextCats = categories.find({ parent: cat._id }).sort(config.index_generator.order_by || 'name').filter(cat => cat.length) %>
<% if (nextCats.length > 0) { %>
<span>></span>
<%- render_category_chain(nextCats.data[0]) %>
<% } %>
<% } %>
<span class="category-chains">
<% var catsFirst = categories.find({ parent: { $exists: false } }).sort(config.index_generator.order_by || 'name').filter(cat => cat.length) %>
<% catsFirst.each((cat, idx) => { %>
<% if (typeof(limit) === "undefined" || idx < limit) { %>
<span class="category-chain">
<%- render_category_chain(cat) %>
</span>
<% } %>
<% }) %>
</span>