sidebar & footer

This commit is contained in:
xaoxuu 2021-07-07 23:56:41 +08:00
parent 29f4a671c2
commit cb7eec2268
4 changed files with 37 additions and 27 deletions

View File

@ -4,16 +4,16 @@ function layoutDiv() {
var title = __('meta.read_next'); var title = __('meta.read_next');
var title_prev = __('meta.prev'); var title_prev = __('meta.prev');
var title_next = __('meta.next'); var title_next = __('meta.next');
if (page.layout == 'post') { if (page.layout === 'post') {
prev = page.prev; prev = page.prev;
next = page.next; next = page.next;
title_prev = __('meta.newer'); title_prev = __('meta.newer');
title_next = __('meta.older'); title_next = __('meta.older');
} else if (page.layout == 'wiki' && page.wiki && page.wiki.length > 0) { } else if (page.layout === 'wiki' && page.wiki && page.wiki.length > 0) {
var wikis = []; var wikis = [];
wikis = site.pages.filter(function (p) { wikis = site.pages.filter(function (p) {
if (p.layout == 'wiki' && p.wiki && p.wiki == page.wiki) { if (p.layout === 'wiki' && p.wiki && p.wiki === page.wiki) {
if (p.order == undefined) { if (p.order === undefined) {
p.order = 0; p.order = 0;
} }
return true; return true;
@ -24,15 +24,18 @@ function layoutDiv() {
page.order = page.order || 0; page.order = page.order || 0;
wikis.forEach((p, i) => { wikis.forEach((p, i) => {
if (p.order < page.order) { if (p.order < page.order) {
if (prev == undefined || p.order > prev.order) { if (prev === undefined || p.order > prev.order) {
prev = p; prev = p;
} }
} else if (p.order > page.order) { } else if (p.order > page.order) {
if (next == undefined || p.order < next.order) { if (next === undefined || p.order < next.order) {
next = p; next = p;
} }
} }
}); });
if (next === undefined) {
return '<br>';
}
} }
let el = ''; let el = '';
if (prev || next) { if (prev || next) {

View File

@ -3,7 +3,23 @@ var proj;
if (page.layout === 'wiki' && page.wiki) { if (page.layout === 'wiki' && page.wiki) {
proj = theme.wiki.projects[page.wiki]; proj = theme.wiki.projects[page.wiki];
} }
function layoutTitle(main, url, sub) {
var el = '';
el += '<a class="title" href="' + url_for(url || "/") + '">';
el += '<div class="main">' + main + '</div>';
if (sub) {
let arr = sub.split('|');
console.log(arr);
if (arr.length > 1) {
el += '<div class="sub normal cap">' + arr[0].trim() + '</div>';
el += '<div class="sub hover cap" style="opacity:0">' + arr[1].trim() + '</div>';
} else if (arr.length > 0) {
el += '<div class="sub cap">' + arr[0] + '</div>';
}
}
el += '</a>';
return el;
}
function layoutDiv() { function layoutDiv() {
var el = ''; var el = '';
if (page.layout === 'wiki' && proj.index !== false) { if (page.layout === 'wiki' && proj.index !== false) {
@ -24,9 +40,10 @@ function layoutDiv() {
} }
} }
if (proj !== undefined) { if (proj !== undefined) {
el += '<a class="title" href="' + url_for(proj.path) + '">'; let main = proj.title || proj.wiki || page.wiki || page.title;
el += proj.title || proj.wiki; let url = proj.path;
el += '</a>'; let sub = proj.subtitle;
el += layoutTitle(main, url, sub);
} }
} else { } else {
el += '<div class="logo-wrap">'; el += '<div class="logo-wrap">';
@ -38,19 +55,11 @@ function layoutDiv() {
el += '<img no-lazy class="avatar" src="' + md_text(theme.sidebar.logo.avatar) + '">'; el += '<img no-lazy class="avatar" src="' + md_text(theme.sidebar.logo.avatar) + '">';
el += '</a>'; el += '</a>';
} }
if (md_text(theme.sidebar.logo.title)) { let main = md_text(theme.sidebar.logo.title);
el += '<a class="title" href="' + url_for(md_link(theme.sidebar.logo.title) || "/") + '">'; if (main) {
el += '<div class="main">' + md_text(theme.sidebar.logo.title) + '</div>'; let url = md_link(theme.sidebar.logo.title);
if (config.subtitle) { let sub = config.subtitle;
let arr = config.subtitle.split('|'); el += layoutTitle(main, url, sub);
if (arr.length > 0) {
el += '<div class="sub normal cap">' + arr[0] + '</div>';
if (arr.length > 1) {
el += '<div class="sub hover cap" style="opacity:0">' + arr[1] + '</div>';
}
}
}
el += '</a>';
} }
} }
el += '</div>'; el += '</div>';

View File

@ -1,5 +1,5 @@
.page-footer .page-footer
margin: 4rem 1rem 2rem margin: 4rem 1rem
color: var(--text-p3) color: var(--text-p3)
a a
color: var(--text-p3) color: var(--text-p3)
@ -7,7 +7,7 @@
color: $color-hover color: $color-hover
.page-footer .sitemap .page-footer .sitemap
margin: .5rem 0 1.5rem margin: .5rem 0 2rem
display: grid display: grid
grid-gap: 1rem 1rem grid-gap: 1rem 1rem
grid-auto-flow: column dense grid-auto-flow: column dense

View File

@ -81,8 +81,6 @@
.hover .hover
transform: translateY(0) transform: translateY(0)
opacity: 1 !important opacity: 1 !important
a.avatar+a.title
txt-ellipsis()
.logo-wrap.wiki .logo-wrap.wiki