This commit is contained in:
xaoxuu 2021-02-27 17:15:47 +08:00
parent 254c29c6fe
commit 1dbbe0883c
3 changed files with 95 additions and 63 deletions

View File

@ -49,4 +49,7 @@ if (post.categories && post.categories.length > 0) {
<%- layoutCats() %> <%- layoutCats() %>
<% } %> <% } %>
<% } %> <% } %>
<% if (post.pin) { %>
<span class='pin'><img src='https://7.dusays.com/2021/02/27/3279dd441df8b.svg'/></span>
<% } %>
</div> </div>

View File

@ -9,44 +9,52 @@ if (page.menu_id == undefined) {
if (page.title && page.wiki) { if (page.title && page.wiki) {
page.robots = 'noindex,follow'; page.robots = 'noindex,follow';
} }
function layout_h1() {
if (is_home()) { function layout_post_card(type, post, content) {
return ''; var el = '';
} el += '<a class="post-card ' + type + scrollreveal() + '" href="' + url_for(post.link || post.path) + '">';
var el = '<h1 class="list-title">'; el += '<article class="excerpt md">';
el += __('page.filter', config.title, page.category || page.tag, page.posts.length); el += content;
el += '</h1>'; el += '</article></a>';
return el; return el;
} }
%>
<% if (page.menu_id == 'post') { %> function layout_posts(partial) {
<%- partial('_partial/main/navbar/list_post') %> var el = '';
<% if (page.posts) { %> el += '<div class="post-list post">';
<div class='post-list post'> if (is_home()) {
<%- layout_h1() %> // pinned posts
<% page.posts.each(function(post){ %> if (page.current == 1) {
<a class='post-card post<%- scrollreveal() %>' href='<%- url_for(post.link || post.path) %>'> var pinned = site.posts.filter(function(post){
<article class='excerpt md'> return post.pin != undefined;
<%- partial('_partial/main/post_list/post_card', {post: post}) %> }).sort((config.index_generator && config.index_generator.order_by) || '-date');
</article> pinned.forEach((post, i) => {
</a> el += layout_post_card('post', post, partial(post));
<% }) %> });
<%- partial('_partial/main/post_list/paginator') %> }
</div> // unpinned posts
<% } %> page.posts.each(function(post){
<% } else if (page.menu_id == 'wiki') { %> if (post.pin == undefined) {
<% function outputExcerpt(post) { %> el += layout_post_card('post', post, partial(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}) %> } else {
</article> el += '<h1 class="list-title">';
</a> el += __('page.filter', config.title, page.category || page.tag, page.posts.length);
<% } %> el += '</h1>';
<%- partial('_partial/main/navbar/list_wiki') %> page.posts.each(function(post){
<% if (page.title && page.wiki) { %> el += layout_post_card('post', post, partial(post));
<div class='post-list wiki filter'> })
<% }
el += '</div>';
return el;
}
function layout_wikis(partial) {
var el = '';
var wikis = []; var wikis = [];
if (page.title && page.wiki) {
// filtered wikis
page.wiki.forEach((wiki, i) => { page.wiki.forEach((wiki, i) => {
site.pages.filter(function (p) { site.pages.filter(function (p) {
return p.layout == 'wiki' && p.wiki == wiki && p.description; return p.layout == 'wiki' && p.wiki == wiki && p.description;
@ -54,16 +62,14 @@ function layout_h1() {
wikis.push(post); wikis.push(post);
}); });
}); });
%> el += '<div class="post-list wiki filter">';
<h1 class='list-title'><%- __('page.wiki', config.title, wikis.length, page.title) %></h1> el += '<h1 class="list-title">' + __("page.wiki", config.title, wikis.length, page.title) + '</h1>';
<% wikis.forEach(function(post) { %> wikis.forEach(function(wiki) {
<%- outputExcerpt(post) %> el += layout_post_card('wiki', wiki, partial(wiki));
<% }); %> });
</div> el += '</div>';
<% } else { %> } else {
<div class='post-list wiki'> // all wikis
<%
var wikis = [];
wikis = site.pages.filter(function (p) { wikis = site.pages.filter(function (p) {
if (p.layout == 'wiki' && p.wiki && p.description) { if (p.layout == 'wiki' && p.wiki && p.description) {
if (p.order == undefined) { if (p.order == undefined) {
@ -74,11 +80,26 @@ function layout_h1() {
return false; return false;
} }
}).sort('order'); }).sort('order');
%> el += '<div class="post-list wiki">';
<h1 class='list-title'><%- __('page.wiki', config.title, wikis.length, __('btn.wiki')) %></h1> el += '<h1 class="list-title">' + __("page.wiki", config.title, wikis.length, __('btn.wiki')) + '</h1>';
<% wikis.forEach(function(post) { %> wikis.forEach(function(wiki) {
<%- outputExcerpt(post) %> el += layout_post_card('wiki', wiki, partial(wiki));
<% }); %> });
</div> 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})
}) %>
<% } %> <% } %>

View File

@ -25,9 +25,17 @@
overflow: hidden overflow: hidden
background: var(--card) background: var(--card)
.meta.cap .meta.cap
display: flex
flex-wrap: wrap
align-items: center
margin-bottom: 0.5rem margin-bottom: 0.5rem
span+span span+span
margin-left: 0.5rem margin-left: 0.5rem
span.pin
line-height: 0
img
object-fit: contain
height: 1.5em
.post-list .post-card:hover .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) box-shadow: 0 2px 8px 0px rgba(0, 0, 0, 0.04), 0 4px 16px 0px rgba(0, 0, 0, 0.04)
.preview img .preview img