2021-02-19 23:33:19 +08:00
|
|
|
<%
|
2021-07-26 22:26:46 +08:00
|
|
|
if (page.menu_id == undefined) {
|
2024-01-14 16:42:20 +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-27 17:15:47 +08:00
|
|
|
|
2021-07-04 20:21:31 +08:00
|
|
|
function layout_post_card(layout, post, content) {
|
2021-02-27 17:15:47 +08:00
|
|
|
var el = '';
|
2021-12-12 16:24:33 +08:00
|
|
|
var layout = layout;
|
2022-11-05 00:13:32 +08:00
|
|
|
if (layout == 'post' && post.cover != undefined && post.poster != undefined) {
|
2021-12-12 16:24:33 +08:00
|
|
|
layout += ' photo';
|
|
|
|
}
|
2024-01-19 01:05:44 +08:00
|
|
|
el += `<a class="post-card${scrollreveal(' ')} ${layout}" href="${url_for(post.link || post.path)}">`
|
2021-02-27 17:15:47 +08:00
|
|
|
el += content;
|
2021-12-12 16:24:33 +08:00
|
|
|
el += '</a>';
|
2021-02-27 17:15:47 +08:00
|
|
|
return el;
|
|
|
|
}
|
|
|
|
|
2023-12-17 19:39:23 +08:00
|
|
|
function layout_post_list(partial) {
|
2021-02-27 17:15:47 +08:00
|
|
|
var el = '';
|
|
|
|
el += '<div class="post-list post">';
|
2021-02-26 20:02:32 +08:00
|
|
|
if (is_home()) {
|
2021-02-27 17:15:47 +08:00
|
|
|
// pinned posts
|
|
|
|
if (page.current == 1) {
|
2022-11-19 16:08:50 +08:00
|
|
|
var pinned = site.posts.filter(post => post.pin != undefined).sort((config.index_generator && config.index_generator.order_by) || '-date');
|
2021-02-27 17:15:47 +08:00
|
|
|
pinned.forEach((post, i) => {
|
|
|
|
el += layout_post_card('post', post, partial(post));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// unpinned posts
|
|
|
|
page.posts.each(function(post){
|
2021-07-26 22:26:46 +08:00
|
|
|
if (post.pin == undefined) {
|
2021-02-27 17:15:47 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-02-19 23:33:19 +08:00
|
|
|
%>
|
2021-02-27 17:15:47 +08:00
|
|
|
|
2024-01-14 16:42:20 +08:00
|
|
|
<%- partial('_partial/main/navbar/nav_tabs_blog') %>
|
|
|
|
<%- layout_post_list(function(post){
|
|
|
|
return partial('_partial/main/post_list/post_card', {post: post})
|
|
|
|
}) %>
|
|
|
|
<%- partial('_partial/main/post_list/paginator') %>
|