88 lines
2.5 KiB
Plaintext
Executable File
88 lines
2.5 KiB
Plaintext
Executable File
<%
|
|
if (page.menu_id == undefined) {
|
|
if (page.layout === 'wiki_index' && page.wiki) {
|
|
page.menu_id = 'wiki';
|
|
} else {
|
|
page.menu_id = 'post';
|
|
}
|
|
}
|
|
if (page.title && page.wiki) {
|
|
page.robots = 'noindex,follow';
|
|
}
|
|
|
|
function layout_post_card(layout, post, content) {
|
|
var el = '';
|
|
var layout = layout;
|
|
if (layout == 'post' && post.cover != undefined && post.poster != undefined) {
|
|
layout += ' photo';
|
|
}
|
|
el += '<a class="post-card ' + layout + ' ' + scrollreveal() + '" href="' + url_for(post.link || post.path) + '">';
|
|
el += content;
|
|
el += '</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(post => 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 {
|
|
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 = [];
|
|
const projects = theme.wiki.projects;
|
|
for (let proj_name of Object.keys(projects)) {
|
|
let proj = projects[proj_name];
|
|
if (proj.index === false || proj.pages == undefined || proj.pages.length === 0) {
|
|
continue;
|
|
}
|
|
if (page.filter === false) {
|
|
// all wikis
|
|
el += '<div class="post-list wiki">';
|
|
el += layout_post_card('wiki', proj.homepage, partial(proj));
|
|
el += '</div>';
|
|
} else if (proj.tags && proj.tags.includes(page.tagName) === true) {
|
|
// filtered wikis
|
|
el += '<div class="post-list wiki filter">';
|
|
el += layout_post_card('wiki', proj.homepage, partial(proj));
|
|
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(proj){
|
|
return partial('_partial/main/post_list/wiki_card', {proj: proj})
|
|
}) %>
|
|
<% } %>
|