hexo-theme-stellar/layout/index.ejs

85 lines
2.5 KiB
Plaintext
Raw Normal View History

2021-02-19 23:33:19 +08:00
<%
2021-02-21 03:13:21 +08:00
if (page.menu_id == undefined) {
2021-02-19 23:33:19 +08:00
if (page.layout == 'index' && page.title && page.wiki) {
2021-02-21 03:13:21 +08:00
page.menu_id = 'wiki';
2021-02-19 23:33:19 +08:00
} else {
2021-02-21 03:13:21 +08:00
page.menu_id = 'post';
2021-02-19 23:33:19 +08:00
}
}
2021-02-21 13:44:11 +08:00
if (page.title && page.wiki) {
page.robots = 'noindex,follow';
}
2021-02-26 20:02:32 +08:00
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;
}
2021-02-19 23:33:19 +08:00
%>
2021-02-21 03:13:21 +08:00
<% if (page.menu_id == 'post') { %>
2021-02-20 13:09:41 +08:00
<%- partial('_partial/main/navbar/list_post') %>
2021-02-19 23:33:19 +08:00
<% if (page.posts) { %>
<div class='post-list post'>
2021-02-26 20:02:32 +08:00
<%- layout_h1() %>
2021-02-19 23:33:19 +08:00
<% page.posts.each(function(post){ %>
2021-02-22 13:19:21 +08:00
<a class='post-card post<%- scrollreveal() %>' href='<%- url_for(post.link || post.path) %>'>
2021-02-19 23:33:19 +08:00
<article class='excerpt md'>
2021-02-20 13:09:41 +08:00
<%- partial('_partial/main/post_list/post_card', {post: post}) %>
2021-02-19 23:33:19 +08:00
</article>
</a>
<% }) %>
2021-02-20 13:09:41 +08:00
<%- partial('_partial/main/post_list/paginator') %>
2021-02-19 23:33:19 +08:00
</div>
<% } %>
2021-02-21 03:13:21 +08:00
<% } else if (page.menu_id == 'wiki') { %>
2021-02-19 23:33:19 +08:00
<% function outputExcerpt(post) { %>
2021-02-22 13:19:21 +08:00
<a class='post-card wiki<%- scrollreveal() %>' href='<%- url_for(post.link || post.path) %>'>
2021-02-19 23:33:19 +08:00
<article class='excerpt md'>
2021-02-20 13:09:41 +08:00
<%- partial('_partial/main/post_list/wiki_card', {post: post}) %>
2021-02-19 23:33:19 +08:00
</article>
</a>
<% } %>
2021-02-20 13:09:41 +08:00
<%- partial('_partial/main/navbar/list_wiki') %>
2021-02-19 23:33:19 +08:00
<% if (page.title && page.wiki) { %>
<div class='post-list wiki filter'>
2021-02-26 20:02:32 +08:00
<%
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) %>
2021-02-19 23:33:19 +08:00
<% }); %>
</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');
%>
2021-02-26 20:02:32 +08:00
<h1 class='list-title'><%- __('page.wiki', config.title, wikis.length, __('btn.wiki')) %></h1>
2021-02-19 23:33:19 +08:00
<% wikis.forEach(function(post) { %>
<%- outputExcerpt(post) %>
<% }); %>
</div>
<% } %>
<% } %>