2021-02-20 13:09:41 +08:00
|
|
|
<%
|
|
|
|
function layoutDiv() {
|
|
|
|
var prev,next;
|
|
|
|
var title = __('meta.read_next');
|
2021-06-26 12:40:13 +08:00
|
|
|
var title_prev = __('meta.prev');
|
|
|
|
var title_next = __('meta.next');
|
2021-07-07 23:56:41 +08:00
|
|
|
if (page.layout === 'post') {
|
2021-03-13 13:32:45 +08:00
|
|
|
prev = page.prev;
|
|
|
|
next = page.next;
|
2021-06-26 12:40:13 +08:00
|
|
|
title_prev = __('meta.newer');
|
|
|
|
title_next = __('meta.older');
|
2021-07-07 23:56:41 +08:00
|
|
|
} else if (page.layout === 'wiki' && page.wiki && page.wiki.length > 0) {
|
2021-07-26 22:26:46 +08:00
|
|
|
let proj = theme.wiki.projects[page.wiki];
|
|
|
|
if (proj) {
|
2021-07-29 23:00:40 +08:00
|
|
|
const current = page.order || 0;
|
2021-07-26 22:26:46 +08:00
|
|
|
proj.pages.forEach((p, i) => {
|
2021-07-29 23:00:40 +08:00
|
|
|
if (p.order < current) {
|
2021-07-26 22:26:46 +08:00
|
|
|
if (prev == undefined || p.order > prev.order) {
|
|
|
|
prev = p;
|
|
|
|
}
|
2021-07-29 23:00:40 +08:00
|
|
|
} else if (p.order > current) {
|
2021-07-26 22:26:46 +08:00
|
|
|
if (next == undefined || p.order < next.order) {
|
|
|
|
next = p;
|
|
|
|
}
|
2021-02-20 13:09:41 +08:00
|
|
|
}
|
2021-07-26 22:26:46 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
if (next == undefined) {
|
|
|
|
// 项目的最后一篇文档
|
2021-07-07 23:56:41 +08:00
|
|
|
return '<br>';
|
|
|
|
}
|
2021-02-20 13:09:41 +08:00
|
|
|
}
|
2021-02-25 20:49:43 +08:00
|
|
|
let el = '';
|
2021-02-20 13:09:41 +08:00
|
|
|
if (prev || next) {
|
2021-07-13 22:25:24 +08:00
|
|
|
el += '<div class="related-wrap reveal" 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>';
|
2021-06-26 12:40:13 +08:00
|
|
|
el += '<section class="body fs14">';
|
2021-02-20 13:09:41 +08:00
|
|
|
if (next) {
|
2021-06-26 12:40:13 +08:00
|
|
|
el += '<a id="next" href="' + url_for(next.path) + '">';
|
2021-02-25 20:49:43 +08:00
|
|
|
el += next.title || next.seo_title || next.wiki;
|
2021-06-26 12:40:13 +08:00
|
|
|
el += '<span class="note">' + title_next + '</span>';
|
2021-02-25 20:49:43 +08:00
|
|
|
el += '</a>';
|
2021-02-20 13:09:41 +08:00
|
|
|
}
|
2021-06-26 12:40:13 +08:00
|
|
|
el += '<div class="line"></div>';
|
2021-02-20 13:09:41 +08:00
|
|
|
if (prev) {
|
2021-06-26 12:40:13 +08:00
|
|
|
el += '<a id="prev" href="' + url_for(prev.path) + '">';
|
2021-02-25 20:49:43 +08:00
|
|
|
el += prev.title || prev.seo_title || prev.wiki;
|
2021-06-26 12:40:13 +08:00
|
|
|
el += '<span class="note">' + title_prev + '</span>';
|
|
|
|
el += '</a>';
|
|
|
|
}
|
|
|
|
if (page.layout == 'post') {
|
|
|
|
el += '<div class="line"></div>';
|
|
|
|
el += '<a id="more" href="' + url_for(config.archive_dir) + '">';
|
|
|
|
el += __('meta.all_articles');
|
2021-02-25 20:49:43 +08:00
|
|
|
el += '</a>';
|
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(); %>
|