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

55 lines
2.6 KiB
Plaintext
Raw Normal View History

2021-03-13 13:32:45 +08:00
<%
function layoutDiv() {
2024-01-17 00:27:48 +08:00
var el = '<widget class="widget-wrapper post-list">';
2021-03-13 13:32:45 +08:00
// header
2024-01-17 00:27:48 +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
2021-07-26 22:26:46 +08:00
var arr = [];
if (page.menu_id == 'wiki') {
2022-11-19 16:08:50 +08:00
arr = theme.wiki.all_pages.filter( p => {
2021-07-26 22:26:46 +08:00
if (p.wiki) {
2023-12-06 13:20:04 +08:00
let proj = theme.wiki.tree[p.wiki];
return proj?.index != false;
2021-07-26 22:26:46 +08:00
}
2022-11-19 16:08:50 +08:00
return false
})
2022-11-19 23:14:41 +08:00
arr = arr.sort((p1, p2) => p1.updated > p2.updated ? -1 : 1)
2021-07-26 22:26:46 +08:00
} else {
2022-11-19 16:08:50 +08:00
arr = site.posts.filter( p => p.title && p.title.length > 0)
2022-11-19 23:14:41 +08:00
arr = arr.sort("updated", -1)
2021-07-26 22:26:46 +08:00
}
2024-01-17 00:27:48 +08:00
el += '<div class="widget-body fs14">';
2022-11-19 16:08:50 +08:00
arr.length = item.limit
arr.forEach(post => {
2022-11-22 23:33:52 +08:00
if (!post) { return }
2024-01-17 00:27:48 +08:00
const isActive = post.path == page.path
el += `<a class="item title${post.path == page.path ? ' active' : ''}" href="${url_for(post.link || post.path)}">`
2022-10-25 13:57:31 +08:00
el += '<span class="title">'
2021-07-28 00:47:38 +08:00
if (post.layout == 'wiki') {
2023-12-06 13:20:04 +08:00
let proj = theme.wiki.tree[post.wiki];
2022-11-23 23:17:24 +08:00
let name = proj?.name || post?.wiki;
if (name) {
el += '<strong>' + name + '</strong>' + '<span class="dot"></span>';
2021-07-07 01:18:13 +08:00
}
}
2022-10-25 13:57:31 +08:00
el += (post.title || post.seo_title || post.wiki) + '</span>';
2024-01-17 00:27:48 +08:00
if (isActive) {
el += `<svg t="1705415018387" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="14793" width="200" height="200"><path d="M256 896a42.666667 42.666667 0 0 1-20.906667-5.546667A42.666667 42.666667 0 0 1 213.333333 853.333333V227.413333A97.28 97.28 0 0 1 307.2 128h409.6A97.28 97.28 0 0 1 810.666667 227.413333V853.333333a42.666667 42.666667 0 0 1-21.333334 36.693334 42.666667 42.666667 0 0 1-42.666666 0l-241.92-136.96-227.413334 136.533333A42.666667 42.666667 0 0 1 256 896z" p-id="14794"></path></svg>`
}
2021-03-13 13:32:45 +08:00
el += '</a>';
el += '';
});
el += '</div>';
2022-11-23 21:54:21 +08:00
el += '</widget>';
2021-03-13 13:32:45 +08:00
return el;
}
%>
<%- layoutDiv() %>