109 lines
3.1 KiB
Plaintext
Executable File
109 lines
3.1 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_post_card(type, post, content) {
|
|
var el = '';
|
|
if (post.post == undefined) {
|
|
post.post = 'article';
|
|
}
|
|
el += '<a class="post-card ' + type + ' ' + post.post + scrollreveal() + '" href="' + url_for(post.link || post.path) + '">';
|
|
el += '<article class="excerpt md">';
|
|
el += content;
|
|
el += '</article></a>';
|
|
return el;
|
|
}
|
|
|
|
function layout_posts(partial) {
|
|
var el = '';
|
|
el += '<div class="post-list post">';
|
|
if (is_home()) {
|
|
// pinned posts
|
|
if (page.current == 1) {
|
|
var pinned = site.posts.filter(function(post){
|
|
return post.pin != undefined;
|
|
}).sort((config.index_generator && config.index_generator.order_by) || '-date');
|
|
pinned.forEach((post, i) => {
|
|
el += layout_post_card('post', post, partial(post));
|
|
});
|
|
}
|
|
// unpinned posts
|
|
page.posts.each(function(post){
|
|
if (post.pin == undefined) {
|
|
el += layout_post_card('post', post, partial(post));
|
|
}
|
|
})
|
|
} else {
|
|
el += '<h1 class="list-title h4">';
|
|
el += __('page.filter', config.title, page.category || page.tag, page.posts.length);
|
|
el += '</h1>';
|
|
page.posts.each(function(post){
|
|
el += layout_post_card('post', post, partial(post));
|
|
})
|
|
}
|
|
el += '</div>';
|
|
return el;
|
|
}
|
|
|
|
function layout_wikis(partial) {
|
|
var el = '';
|
|
var wikis = [];
|
|
if (page.title && page.wiki) {
|
|
// filtered 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);
|
|
});
|
|
});
|
|
el += '<div class="post-list wiki filter">';
|
|
el += '<h1 class="list-title h4">' + __("page.wiki", config.title, wikis.length, page.title) + '</h1>';
|
|
wikis.forEach(function(wiki) {
|
|
el += layout_post_card('wiki', wiki, partial(wiki));
|
|
});
|
|
el += '</div>';
|
|
} else {
|
|
// all 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');
|
|
el += '<div class="post-list wiki">';
|
|
el += '<h1 class="list-title h4">' + __("page.wiki", config.title, wikis.length, __('btn.wiki')) + '</h1>';
|
|
wikis.forEach(function(wiki) {
|
|
el += layout_post_card('wiki', wiki, partial(wiki));
|
|
});
|
|
el += '</div>';
|
|
}
|
|
return el;
|
|
}
|
|
%>
|
|
|
|
<% if (page.menu_id == 'post') { %>
|
|
<%- partial('_partial/main/navbar/list_post') %>
|
|
<%- layout_posts(function(post){
|
|
return partial('_partial/main/post_list/post_card', {post: post})
|
|
}) %>
|
|
<%- partial('_partial/main/post_list/paginator') %>
|
|
<% } else if (page.menu_id == 'wiki') { %>
|
|
<%- partial('_partial/main/navbar/list_wiki') %>
|
|
<%- layout_wikis(function(post){
|
|
return partial('_partial/main/post_list/wiki_card', {post: post})
|
|
}) %>
|
|
<% } %>
|