64 lines
1.8 KiB
Plaintext
64 lines
1.8 KiB
Plaintext
<%
|
|
function layoutDiv() {
|
|
var prev,next
|
|
var title = __('meta.read_next')
|
|
title_prev = __('meta.newer')
|
|
title_next = __('meta.older')
|
|
if (page.layout === 'post') {
|
|
prev = page.prev
|
|
next = page.next
|
|
} else if (page.wiki?.length > 0) {
|
|
var title_prev = __('meta.prev');
|
|
var title_next = __('meta.next');
|
|
const proj = theme.wiki.tree[page.wiki];
|
|
if (proj) {
|
|
let ps = proj.pages?.filter(p => p.path == page.path)
|
|
if (ps?.length > 0) {
|
|
const current_page_number = ps[0].page_number || 0;
|
|
proj.pages.forEach((p, i) => {
|
|
if (p.page_number < current_page_number) {
|
|
if (prev == undefined || p.page_number > prev.page_number) {
|
|
prev = p;
|
|
}
|
|
} else if (p.page_number > current_page_number) {
|
|
if (next == undefined || p.page_number < next.page_number) {
|
|
next = p;
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
console.error('未找到当前页');
|
|
}
|
|
}
|
|
}
|
|
let el = '';
|
|
if (prev || next) {
|
|
el += `<div class="related-wrap${scrollreveal(' ')}" id="read-next">`
|
|
el += '<section class="body">';
|
|
// prev
|
|
el += '<div class="item" id="prev">';
|
|
if (prev) {
|
|
el += '<div class="note">' + title_prev + '</div>';
|
|
el += '<a href="' + url_for(prev.path) + '">';
|
|
el += prev.title || prev.wiki || date(prev.date, config.date_format);
|
|
el += '</a>';
|
|
}
|
|
el += '</div>';
|
|
// next
|
|
el += '<div class="item" id="next">';
|
|
if (next) {
|
|
el += '<div class="note">' + title_next + '</div>';
|
|
el += '<a href="' + url_for(next.path) + '">';
|
|
el += next.title || next.wiki || date(next.date, config.date_format);
|
|
el += '</a>';
|
|
}
|
|
el += '</div>';
|
|
|
|
el += '</section>';
|
|
el += '</div>';
|
|
}
|
|
return el;
|
|
}
|
|
%>
|
|
<%- layoutDiv(); %>
|