59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
<%
|
|
function layoutDiv() {
|
|
var prev,next;
|
|
var title = __('meta.read_next');
|
|
var title_prev = __('meta.prev');
|
|
var title_next = __('meta.next');
|
|
if (page.layout === 'post') {
|
|
prev = page.prev;
|
|
next = page.next;
|
|
title_prev = __('meta.newer');
|
|
title_next = __('meta.older');
|
|
} else if (page.layout === 'wiki' && page.wiki && page.wiki.length > 0) {
|
|
let proj = theme.wiki.projects[page.wiki];
|
|
if (proj) {
|
|
const current = page.order || 0;
|
|
proj.pages.forEach((p, i) => {
|
|
if (p.order < current) {
|
|
if (prev == undefined || p.order > prev.order) {
|
|
prev = p;
|
|
}
|
|
} else if (p.order > current) {
|
|
if (next == undefined || p.order < next.order) {
|
|
next = p;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
let el = '';
|
|
if (prev || next) {
|
|
el += '<div class="related-wrap reveal" 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.seo_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.seo_title || next.wiki || date(next.date, config.date_format);
|
|
el += '</a>';
|
|
}
|
|
el += '</div>';
|
|
|
|
el += '</section>';
|
|
el += '</div>';
|
|
}
|
|
return el;
|
|
}
|
|
%>
|
|
<%- layoutDiv(); %>
|