2021-06-26 15:02:32 +08:00
|
|
|
<%
|
2024-01-14 14:10:36 +08:00
|
|
|
function relatedPostsInTopic() {
|
|
|
|
if (page.topic?.length == 0) {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
const topic = theme.topic.tree[page.topic]
|
|
|
|
if (topic == null) {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
var el = ''
|
2024-01-17 00:27:48 +08:00
|
|
|
el += `<widget class="widget-wrapper post-list">`
|
|
|
|
el += `<div class="widget-header cap dis-select">`
|
2024-01-14 14:10:36 +08:00
|
|
|
el += `<span class="name">${__('btn.topic') + __('symbol.colon') + topic.name}</span>`
|
|
|
|
el += `</div>`
|
2024-01-17 00:27:48 +08:00
|
|
|
el += `<div class="widget-body">`
|
2024-01-14 14:10:36 +08:00
|
|
|
for (let post of topic.pages) {
|
2024-01-17 00:27:48 +08:00
|
|
|
const isActive = post.path == page.path
|
|
|
|
el += `<a class="item${isActive ? ' active' : ''}" href="${url_for(post.path)}">`
|
2024-01-14 14:10:36 +08:00
|
|
|
el += `<span class="title">${post.title}</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>`
|
|
|
|
}
|
2024-01-14 14:10:36 +08:00
|
|
|
el += `</a>`
|
|
|
|
}
|
|
|
|
el += `</div>`
|
|
|
|
el += `</widget>`
|
|
|
|
return el
|
|
|
|
}
|
2024-01-13 21:10:26 +08:00
|
|
|
function relatedWiki() {
|
|
|
|
let thisItemObject = theme.wiki.tree[page.wiki]
|
2023-12-17 19:39:23 +08:00
|
|
|
if (thisItemObject == null) {
|
2024-01-13 21:10:26 +08:00
|
|
|
return ''
|
2021-07-26 22:26:46 +08:00
|
|
|
}
|
2024-01-13 21:10:26 +08:00
|
|
|
const relatedItems = thisItemObject.relatedItems
|
|
|
|
var el = ''
|
2023-12-17 19:39:23 +08:00
|
|
|
for (let relatedItem of relatedItems) {
|
2024-01-17 00:27:48 +08:00
|
|
|
el += `<widget class="widget-wrapper post-card">`
|
|
|
|
el += `<div class="widget-header cap dis-select">`
|
2024-01-14 18:50:15 +08:00
|
|
|
el += `<span class="name">${__('meta.more') + __('symbol.colon') + relatedItem.name}</span>`
|
2024-01-13 21:10:26 +08:00
|
|
|
el += `</div>`
|
2024-01-17 00:27:48 +08:00
|
|
|
el += `<div class="widget-body">`
|
2023-12-17 19:39:23 +08:00
|
|
|
for (let id of relatedItem.items) {
|
2021-07-26 22:26:46 +08:00
|
|
|
// 同一个分组中的其它项目
|
2024-01-13 21:10:26 +08:00
|
|
|
let item = theme.wiki.tree[id]
|
|
|
|
el += `<a class="item wiki" href="${url_for(item.homepage?.path)}">`
|
|
|
|
el += `<span class="title">${item.title}</span>`
|
2023-12-17 19:39:23 +08:00
|
|
|
if (item.description && item.description.length > 0) {
|
2024-01-13 21:10:26 +08:00
|
|
|
el += `<span class="excerpt">${item.description}</span>`
|
2022-10-25 13:57:31 +08:00
|
|
|
}
|
2024-01-13 21:10:26 +08:00
|
|
|
el += `</a>`
|
2023-12-07 14:03:41 +08:00
|
|
|
}
|
2024-01-13 21:10:26 +08:00
|
|
|
el += `</div>`
|
|
|
|
el += `</widget>`
|
|
|
|
}
|
|
|
|
return el
|
|
|
|
}
|
|
|
|
function layoutDiv() {
|
|
|
|
if (page.layout == 'wiki') {
|
|
|
|
return relatedWiki()
|
2024-01-14 14:10:36 +08:00
|
|
|
} else if (page.layout == 'topic') {
|
|
|
|
return relatedPostsInTopic()
|
2021-07-04 20:21:31 +08:00
|
|
|
}
|
2021-06-26 15:02:32 +08:00
|
|
|
}
|
|
|
|
%>
|
|
|
|
<%- layoutDiv() %>
|