cover
This commit is contained in:
parent
8045326a85
commit
0c2b7722a1
|
@ -1,16 +1,22 @@
|
||||||
<%
|
<%
|
||||||
|
const obj = {
|
||||||
|
image: post['cover'],
|
||||||
|
title: post['cover-title'],
|
||||||
|
cat: post['cover-cat'],
|
||||||
|
subtitle: post['cover-subtitle']
|
||||||
|
};
|
||||||
function div_default() {
|
function div_default() {
|
||||||
var el = '';
|
var el = '';
|
||||||
el += '<article class="md">';
|
el += '<article class="md">';
|
||||||
|
|
||||||
// 封面
|
// 封面
|
||||||
if (post.cover || theme.article.auto_cover) {
|
if (obj.image || theme.article.auto_cover) {
|
||||||
var cover_url;
|
var cover_url;
|
||||||
if (post.cover != undefined) {
|
if (obj.image != undefined) {
|
||||||
if (post.cover.includes('/')) {
|
if (obj.image.includes('/')) {
|
||||||
cover_url = post.cover;
|
cover_url = obj.image;
|
||||||
} else {
|
} else {
|
||||||
cover_url = 'https://source.unsplash.com/1280x640/?' + post.cover;
|
cover_url = 'https://source.unsplash.com/1280x640/?' + obj.image;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 自动以 tags 作为关键词搜索封面
|
// 自动以 tags 作为关键词搜索封面
|
||||||
|
@ -89,23 +95,22 @@ function div_default() {
|
||||||
function div_photo() {
|
function div_photo() {
|
||||||
var el = '';
|
var el = '';
|
||||||
el += '<div class="cover">';
|
el += '<div class="cover">';
|
||||||
el += '<img src="' + post.cover + '"/>';
|
el += '<img src="' + obj.image + '"/>';
|
||||||
let info = post.cover_info;
|
if (obj.title || obj.cat || obj.subtitle) {
|
||||||
if (info) {
|
|
||||||
el += '<div class="cover-info"';
|
el += '<div class="cover-info"';
|
||||||
if (info.meta) {
|
if (obj.cat) {
|
||||||
el += 'position="top">';
|
el += 'position="top">';
|
||||||
} else {
|
} else {
|
||||||
el += 'position="bottom">';
|
el += 'position="bottom">';
|
||||||
}
|
}
|
||||||
if (info.meta) {
|
if (obj.cat) {
|
||||||
el += '<div class="cap">' + info.meta + '</div>';
|
el += '<div class="cap">' + obj.cat + '</div>';
|
||||||
}
|
}
|
||||||
if (info.title) {
|
if (obj.title) {
|
||||||
el += '<div class="title">' + info.title + '</div>';
|
el += '<div class="title">' + obj.title + '</div>';
|
||||||
}
|
}
|
||||||
if (info.subtitle) {
|
if (obj.subtitle) {
|
||||||
el += '<div class="cap">' + info.subtitle + '</div>';
|
el += '<div class="cap">' + obj.subtitle + '</div>';
|
||||||
}
|
}
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
|
|
||||||
|
@ -114,7 +119,7 @@ function div_photo() {
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
function div() {
|
function div() {
|
||||||
if (post.cover && post.cover.length > 0 && post.cover_info != undefined) {
|
if (obj.image && obj.image.length > 0 && obj.title != undefined) {
|
||||||
return div_photo();
|
return div_photo();
|
||||||
}
|
}
|
||||||
return div_default();
|
return div_default();
|
||||||
|
|
|
@ -13,7 +13,7 @@ if (page.title && page.wiki) {
|
||||||
function layout_post_card(layout, post, content) {
|
function layout_post_card(layout, post, content) {
|
||||||
var el = '';
|
var el = '';
|
||||||
var layout = layout;
|
var layout = layout;
|
||||||
if (layout == 'post' && post.cover != undefined && post.cover_info != undefined) {
|
if (layout == 'post' && post['cover'] != undefined && post['cover-title'] != undefined) {
|
||||||
layout += ' photo';
|
layout += ' photo';
|
||||||
}
|
}
|
||||||
el += '<a class="post-card ' + layout + ' ' + scrollreveal() + '" href="' + url_for(post.link || post.path) + '">';
|
el += '<a class="post-card ' + layout + ' ' + scrollreveal() + '" href="' + url_for(post.link || post.path) + '">';
|
||||||
|
|
Loading…
Reference in New Issue