hexo-theme-stellar/layout/_partial/sidebar/widgets/recent.ejs

52 lines
2.0 KiB
Plaintext
Raw Normal View History

2021-03-13 13:32:45 +08:00
<%
function layoutDiv() {
var el = '<div class="widget-wrap" id="recent">';
// header
2021-07-03 20:49:52 +08:00
el += '<div class="widget-header cap dis-select">';
2021-03-13 13:32:45 +08:00
el += '<span class="name">' + __("meta.recent_update") + '</span>';
if (item.rss) {
el += '<a class="cap-action" id="rss" title="Subscribe" href="' + item.rss + '">';
el += '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8938"><path d="M800.966 947.251c0-404.522-320.872-732.448-716.69-732.448V62.785c477.972 0 865.44 395.987 865.44 884.466h-148.75z m-162.273 0h-148.74c0-228.98-181.628-414.598-405.678-414.598v-152.01c306.205 0 554.418 253.68 554.418 566.608z m-446.24-221.12c59.748 0 108.189 49.503 108.189 110.557 0 61.063-48.44 110.563-108.188 110.563-59.747 0-108.18-49.5-108.18-110.563 0-61.054 48.433-110.556 108.18-110.556z" p-id="8939"></path></svg>';
el += '</a>';
}
el += '</div>';
// body
var arr = page.menu_id == "wiki" ? site.pages.filter(function(p){
return p.layout == "wiki" && p.title && p.title.length > 0;
}) : site.posts.filter(function(p){
return p.title && p.title.length > 0;
});
el += '<div class="widget-body fs14">';
arr.sort("updated", -1).limit(item.limit).each(function(post) {
2021-06-26 12:39:29 +08:00
el += '<div class="line"></div>'
el += '<a class="reveal" href="' + url_for(post.link || post.path) + '">';
2021-03-13 13:32:45 +08:00
el += '<div class="cap">';
2021-03-22 21:13:57 +08:00
el += '<time>' + date(post.updated, config.date_format) + '</time>';
2021-07-07 01:18:13 +08:00
if (post.layout === 'wiki') {
el += '<span>';
let proj = theme.wiki.projects[post.wiki];
if (proj && proj.title) {
el += proj.title;
} else if (post.wiki) {
el += post.wiki;
}
el += '</span>';
} else {
post.categories.limit(1).forEach((cat, i) => {
el += '<span>' + cat.name + '</span>';
});
}
2021-03-13 13:32:45 +08:00
el += '</div>';
2021-06-26 12:39:29 +08:00
el += '<span class="title">';
2021-03-13 13:32:45 +08:00
el += post.title;
2021-06-26 12:39:29 +08:00
el += '</span>';
2021-03-13 13:32:45 +08:00
el += '</a>';
el += '';
});
el += '</div>';
el += '</div>';
return el;
}
%>
<%- layoutDiv() %>