[opt] post.pin -> post.sticky

This commit is contained in:
xaoxuu 2024-01-19 23:19:48 +08:00
parent ef58c7081b
commit f53a89f324
2 changed files with 4 additions and 20 deletions

View File

@ -90,7 +90,7 @@ function div_default() {
} }
} }
} }
if (post.pin) { if (post.sticky) {
el += `<span class="pin">${icon('default:pin')}</span>` el += `<span class="pin">${icon('default:pin')}</span>`
} }
el += '</div>'; el += '</div>';

View File

@ -21,25 +21,9 @@ function layout_post_card(layout, post, content) {
function layout_post_list(partial) { function layout_post_list(partial) {
var el = ''; var el = '';
el += '<div class="post-list post">'; el += '<div class="post-list post">';
if (is_home()) { page.posts.each(function(post){
// pinned posts el += layout_post_card('post', post, partial(post));
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>'; el += '</div>';
return el; return el;
} }