2021-02-20 13:09:41 +08:00
|
|
|
<%
|
|
|
|
function layoutDiv() {
|
|
|
|
var prev,next;
|
|
|
|
var title = __('meta.read_next');
|
|
|
|
var title_prev = __('meta.read_prev');
|
|
|
|
if (page.layout == 'post') {
|
|
|
|
prev = page.next;
|
|
|
|
next = page.prev;
|
|
|
|
title_prev = __('meta.older');
|
|
|
|
} else if (page.layout == 'wiki' && page.wiki && page.wiki.length > 0) {
|
|
|
|
title_prev = __('meta.read_prev');
|
|
|
|
var wikis = [];
|
|
|
|
wikis = site.pages.filter(function (p) {
|
|
|
|
if (p.layout == 'wiki' && p.wiki && p.wiki == page.wiki) {
|
|
|
|
if (p.order == undefined) {
|
|
|
|
p.order = 0;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}).sort('order');
|
2021-02-22 23:22:59 +08:00
|
|
|
page.order = page.order || 0;
|
2021-02-20 13:09:41 +08:00
|
|
|
wikis.forEach((p, i) => {
|
|
|
|
if (p.order < page.order) {
|
|
|
|
if (prev == undefined || p.order > prev.order) {
|
|
|
|
prev = p;
|
|
|
|
}
|
|
|
|
} else if (p.order > page.order) {
|
|
|
|
if (next == undefined || p.order < next.order) {
|
|
|
|
next = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-02-25 20:49:43 +08:00
|
|
|
let el = '';
|
2021-02-20 13:09:41 +08:00
|
|
|
if (prev || next) {
|
2021-02-25 20:49:43 +08:00
|
|
|
el += '<div class="related-wrap" id="read-next">';
|
2021-02-28 18:19:32 +08:00
|
|
|
el += '<section class="header cap theme">';
|
2021-02-25 20:49:43 +08:00
|
|
|
el += '<span>' + title + '</span>';
|
|
|
|
el += '</section>';
|
|
|
|
el += '<section class="body">';
|
2021-02-20 13:09:41 +08:00
|
|
|
if (next) {
|
2021-03-05 21:37:28 +08:00
|
|
|
el += '<div class="post-title h2">';
|
2021-02-25 20:49:43 +08:00
|
|
|
el += '<a href="' + url_for(next.path) + '">';
|
|
|
|
el += next.title || next.seo_title || next.wiki;
|
|
|
|
el += '</a>';
|
|
|
|
el += '</div>';
|
2021-02-20 13:09:41 +08:00
|
|
|
}
|
|
|
|
if (prev) {
|
2021-03-05 21:37:28 +08:00
|
|
|
el += '<div class="post-title fs14">';
|
2021-02-25 20:49:43 +08:00
|
|
|
el += '<a href="' + url_for(prev.path) + '">';
|
|
|
|
el += title_prev + __('symbol.colon');
|
|
|
|
el += prev.title || prev.seo_title || prev.wiki;
|
|
|
|
el += '</a>';
|
|
|
|
el += '</div>';
|
2021-02-20 13:09:41 +08:00
|
|
|
}
|
2021-02-25 20:49:43 +08:00
|
|
|
el += '</section>';
|
|
|
|
el += '</div>';
|
2021-02-20 13:09:41 +08:00
|
|
|
}
|
2021-02-25 20:49:43 +08:00
|
|
|
return el;
|
2021-02-20 13:09:41 +08:00
|
|
|
}
|
|
|
|
%>
|
|
|
|
<%- layoutDiv(); %>
|