2021-12-12 16:24:33 +08:00
|
|
|
<%
|
|
|
|
function div() {
|
|
|
|
var el = '';
|
2022-06-14 20:05:49 +08:00
|
|
|
if ((page.banner == undefined || page.banner == false) && !theme.article.auto_banner) {
|
2021-12-12 16:24:33 +08:00
|
|
|
return el;
|
|
|
|
}
|
2022-06-14 20:05:49 +08:00
|
|
|
var url;
|
|
|
|
if (page.banner != undefined) {
|
|
|
|
if (page.banner.includes('/')) {
|
|
|
|
url = page.banner;
|
|
|
|
} else {
|
|
|
|
url = 'https://source.unsplash.com/2000x400/?' + page.banner;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// 自动以 tags 作为关键词搜索封面
|
|
|
|
if (page.tags) {
|
|
|
|
var params = '';
|
|
|
|
page.tags.reverse().forEach((tag, i) => {
|
|
|
|
if (i > 0) {
|
|
|
|
params += ',';
|
|
|
|
}
|
|
|
|
params += tag.name;
|
|
|
|
});
|
|
|
|
url = 'https://source.unsplash.com/2000x400/?' + params;
|
|
|
|
} else {
|
|
|
|
url = 'https://source.unsplash.com/random/2000x400';
|
|
|
|
}
|
|
|
|
}
|
2024-01-19 01:05:44 +08:00
|
|
|
el += '<div class="l_cover post' + scrollreveal(' ') + '">';
|
2021-12-12 16:24:33 +08:00
|
|
|
el += '<div class="cover">';
|
|
|
|
if (theme.plugins.lazyload && theme.plugins.lazyload.enable) {
|
2022-06-14 20:05:49 +08:00
|
|
|
el += '<div class="lazy img bg" data-bg="' + url + '"></div>';
|
2021-12-12 16:24:33 +08:00
|
|
|
} else {
|
2022-06-14 20:05:49 +08:00
|
|
|
el += '<div class="lazy img bg" style="background-image:url("' + url + '")"></div>';
|
2021-12-12 16:24:33 +08:00
|
|
|
}
|
|
|
|
el += '</div>';
|
|
|
|
el += '</div>';
|
|
|
|
return el;
|
|
|
|
}
|
|
|
|
%>
|
|
|
|
<%- div() %>
|