hexo-theme-stellar/layout/index.ejs

85 lines
2.5 KiB
Plaintext
Executable File

<%
if (page.menu_id == undefined) {
if (page.layout == 'index' && page.title && page.wiki) {
page.menu_id = 'wiki';
} else {
page.menu_id = 'post';
}
}
if (page.title && page.wiki) {
page.robots = 'noindex,follow';
}
function layout_h1() {
if (is_home()) {
return '';
}
var el = '<h1 class="list-title">';
el += __('page.filter', config.title, page.category || page.tag, page.posts.length);
el += '</h1>';
return el;
}
%>
<% if (page.menu_id == 'post') { %>
<%- partial('_partial/main/navbar/list_post') %>
<% if (page.posts) { %>
<div class='post-list post'>
<%- layout_h1() %>
<% page.posts.each(function(post){ %>
<a class='post-card post<%- scrollreveal() %>' href='<%- url_for(post.link || post.path) %>'>
<article class='excerpt md'>
<%- partial('_partial/main/post_list/post_card', {post: post}) %>
</article>
</a>
<% }) %>
<%- partial('_partial/main/post_list/paginator') %>
</div>
<% } %>
<% } else if (page.menu_id == 'wiki') { %>
<% function outputExcerpt(post) { %>
<a class='post-card wiki<%- scrollreveal() %>' href='<%- url_for(post.link || post.path) %>'>
<article class='excerpt md'>
<%- partial('_partial/main/post_list/wiki_card', {post: post}) %>
</article>
</a>
<% } %>
<%- partial('_partial/main/navbar/list_wiki') %>
<% if (page.title && page.wiki) { %>
<div class='post-list wiki filter'>
<%
var wikis = [];
page.wiki.forEach((wiki, i) => {
site.pages.filter(function (p) {
return p.layout == 'wiki' && p.wiki == wiki && p.description;
}).limit(1).each(function(post) {
wikis.push(post);
});
});
%>
<h1 class='list-title'><%- __('page.wiki', config.title, wikis.length, page.title) %></h1>
<% wikis.forEach(function(post) { %>
<%- outputExcerpt(post) %>
<% }); %>
</div>
<% } else { %>
<div class='post-list wiki'>
<%
var wikis = [];
wikis = site.pages.filter(function (p) {
if (p.layout == 'wiki' && p.wiki && p.description) {
if (p.order == undefined) {
p.order = 0;
}
return true;
} else {
return false;
}
}).sort('order');
%>
<h1 class='list-title'><%- __('page.wiki', config.title, wikis.length, __('btn.wiki')) %></h1>
<% wikis.forEach(function(post) { %>
<%- outputExcerpt(post) %>
<% }); %>
</div>
<% } %>
<% } %>