pin
This commit is contained in:
parent
254c29c6fe
commit
1dbbe0883c
|
@ -49,4 +49,7 @@ if (post.categories && post.categories.length > 0) {
|
|||
<%- layoutCats() %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if (post.pin) { %>
|
||||
<span class='pin'><img src='https://7.dusays.com/2021/02/27/3279dd441df8b.svg'/></span>
|
||||
<% } %>
|
||||
</div>
|
||||
|
|
123
layout/index.ejs
123
layout/index.ejs
|
@ -9,44 +9,52 @@ if (page.menu_id == undefined) {
|
|||
if (page.title && page.wiki) {
|
||||
page.robots = 'noindex,follow';
|
||||
}
|
||||
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>';
|
||||
|
||||
function layout_post_card(type, post, content) {
|
||||
var el = '';
|
||||
el += '<a class="post-card ' + type + scrollreveal() + '" href="' + url_for(post.link || post.path) + '">';
|
||||
el += '<article class="excerpt md">';
|
||||
el += content;
|
||||
el += '</article></a>';
|
||||
return el;
|
||||
}
|
||||
%>
|
||||
<% if (page.menu_id == 'post') { %>
|
||||
<%- partial('_partial/main/navbar/list_post') %>
|
||||
<% if (page.posts) { %>
|
||||
<div class='post-list post'>
|
||||
<%- layout_h1() %>
|
||||
<% page.posts.each(function(post){ %>
|
||||
<a class='post-card post<%- scrollreveal() %>' href='<%- url_for(post.link || post.path) %>'>
|
||||
<article class='excerpt md'>
|
||||
<%- partial('_partial/main/post_list/post_card', {post: post}) %>
|
||||
</article>
|
||||
</a>
|
||||
<% }) %>
|
||||
<%- partial('_partial/main/post_list/paginator') %>
|
||||
</div>
|
||||
<% } %>
|
||||
<% } else if (page.menu_id == 'wiki') { %>
|
||||
<% function outputExcerpt(post) { %>
|
||||
<a class='post-card wiki<%- scrollreveal() %>' href='<%- url_for(post.link || post.path) %>'>
|
||||
<article class='excerpt md'>
|
||||
<%- partial('_partial/main/post_list/wiki_card', {post: post}) %>
|
||||
</article>
|
||||
</a>
|
||||
<% } %>
|
||||
<%- partial('_partial/main/navbar/list_wiki') %>
|
||||
<% if (page.title && page.wiki) { %>
|
||||
<div class='post-list wiki filter'>
|
||||
<%
|
||||
|
||||
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">';
|
||||
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;
|
||||
|
@ -54,16 +62,14 @@ function layout_h1() {
|
|||
wikis.push(post);
|
||||
});
|
||||
});
|
||||
%>
|
||||
<h1 class='list-title'><%- __('page.wiki', config.title, wikis.length, page.title) %></h1>
|
||||
<% wikis.forEach(function(post) { %>
|
||||
<%- outputExcerpt(post) %>
|
||||
<% }); %>
|
||||
</div>
|
||||
<% } else { %>
|
||||
<div class='post-list wiki'>
|
||||
<%
|
||||
var wikis = [];
|
||||
el += '<div class="post-list wiki filter">';
|
||||
el += '<h1 class="list-title">' + __("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) {
|
||||
|
@ -74,11 +80,26 @@ function layout_h1() {
|
|||
return false;
|
||||
}
|
||||
}).sort('order');
|
||||
el += '<div class="post-list wiki">';
|
||||
el += '<h1 class="list-title">' + __("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;
|
||||
}
|
||||
%>
|
||||
<h1 class='list-title'><%- __('page.wiki', config.title, wikis.length, __('btn.wiki')) %></h1>
|
||||
<% wikis.forEach(function(post) { %>
|
||||
<%- outputExcerpt(post) %>
|
||||
<% }); %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% 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})
|
||||
}) %>
|
||||
<% } %>
|
||||
|
|
|
@ -25,9 +25,17 @@
|
|||
overflow: hidden
|
||||
background: var(--card)
|
||||
.meta.cap
|
||||
display: flex
|
||||
flex-wrap: wrap
|
||||
align-items: center
|
||||
margin-bottom: 0.5rem
|
||||
span+span
|
||||
margin-left: 0.5rem
|
||||
span.pin
|
||||
line-height: 0
|
||||
img
|
||||
object-fit: contain
|
||||
height: 1.5em
|
||||
.post-list .post-card:hover
|
||||
box-shadow: 0 2px 8px 0px rgba(0, 0, 0, 0.04), 0 4px 16px 0px rgba(0, 0, 0, 0.04)
|
||||
.preview img
|
||||
|
|
Loading…
Reference in New Issue