47 lines
1.3 KiB
Plaintext
47 lines
1.3 KiB
Plaintext
<%
|
|
function layoutDiv() {
|
|
if (page.layout !== "wiki") {
|
|
return '';
|
|
}
|
|
var related = [];
|
|
const { shelf, tree } = theme.wiki;
|
|
let proj = tree[page.wiki];
|
|
if (proj?.related?.length > 0) {
|
|
proj.related.filter(pid => shelf.includes(pid)).forEach((pid, i) => {
|
|
let p = tree[pid];
|
|
if (p && p.title !== proj?.title) {
|
|
related.push(p);
|
|
}
|
|
});
|
|
}
|
|
var el = '';
|
|
if (related.length > 0) {
|
|
el += '<widget class="widget-wrapper related">';
|
|
el += '<div class="widget-header cap theme dis-select">';
|
|
var title = __('btn.wiki');
|
|
if (proj.tags && proj.tags[0]) {
|
|
title = proj.tags[0];
|
|
}
|
|
el += '<span class="name">' + __('meta.more', title) + '</span>';
|
|
el += '</div>';
|
|
el += '<div class="widget-body related-posts">';
|
|
related.forEach((p, i) => {
|
|
if (p.homepage == null) {
|
|
console.error("未找到首页:", p.title);
|
|
}
|
|
// 同一个分组中的其它项目
|
|
el += '<a class="item wiki" href="' + url_for(p.homepage?.path) + '">';
|
|
el += '<span class="title">' + p.title + '</span>';
|
|
if (p.description && p.description.length > 0) {
|
|
el += '<span class="excerpt">' + p.description + '</span>';
|
|
}
|
|
el += '</a>';
|
|
});
|
|
el += '</div>';
|
|
el += '</widget>';
|
|
}
|
|
return el;
|
|
}
|
|
%>
|
|
<%- layoutDiv() %>
|