From cb7eec226876c39b271188a13fcd42f31136151f Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Wed, 7 Jul 2021 23:56:41 +0800 Subject: [PATCH] sidebar & footer --- layout/_partial/main/article/read_next.ejs | 15 +++++--- layout/_partial/sidebar/logo.ejs | 43 +++++++++++++--------- source/css/_layout/partial/footer.styl | 4 +- source/css/_layout/sidebar/sidebar.styl | 2 - 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/layout/_partial/main/article/read_next.ejs b/layout/_partial/main/article/read_next.ejs index cbdb120..98b549e 100644 --- a/layout/_partial/main/article/read_next.ejs +++ b/layout/_partial/main/article/read_next.ejs @@ -4,16 +4,16 @@ function layoutDiv() { var title = __('meta.read_next'); var title_prev = __('meta.prev'); var title_next = __('meta.next'); - if (page.layout == 'post') { + 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) { + } else if (page.layout === 'wiki' && page.wiki && page.wiki.length > 0) { var wikis = []; wikis = site.pages.filter(function (p) { - if (p.layout == 'wiki' && p.wiki && p.wiki == page.wiki) { - if (p.order == undefined) { + if (p.layout === 'wiki' && p.wiki && p.wiki === page.wiki) { + if (p.order === undefined) { p.order = 0; } return true; @@ -24,15 +24,18 @@ function layoutDiv() { page.order = page.order || 0; wikis.forEach((p, i) => { if (p.order < page.order) { - if (prev == undefined || p.order > prev.order) { + if (prev === undefined || p.order > prev.order) { prev = p; } } else if (p.order > page.order) { - if (next == undefined || p.order < next.order) { + if (next === undefined || p.order < next.order) { next = p; } } }); + if (next === undefined) { + return '
'; + } } let el = ''; if (prev || next) { diff --git a/layout/_partial/sidebar/logo.ejs b/layout/_partial/sidebar/logo.ejs index 8cf8e4c..80b59b1 100644 --- a/layout/_partial/sidebar/logo.ejs +++ b/layout/_partial/sidebar/logo.ejs @@ -3,7 +3,23 @@ var proj; if (page.layout === 'wiki' && page.wiki) { proj = theme.wiki.projects[page.wiki]; } - +function layoutTitle(main, url, sub) { + var el = ''; + el += ''; + el += '
' + main + '
'; + if (sub) { + let arr = sub.split('|'); + console.log(arr); + if (arr.length > 1) { + el += '
' + arr[0].trim() + '
'; + el += '
' + arr[1].trim() + '
'; + } else if (arr.length > 0) { + el += '
' + arr[0] + '
'; + } + } + el += '
'; + return el; +} function layoutDiv() { var el = ''; if (page.layout === 'wiki' && proj.index !== false) { @@ -24,9 +40,10 @@ function layoutDiv() { } } if (proj !== undefined) { - el += ''; - el += proj.title || proj.wiki; - el += ''; + let main = proj.title || proj.wiki || page.wiki || page.title; + let url = proj.path; + let sub = proj.subtitle; + el += layoutTitle(main, url, sub); } } else { el += '
'; @@ -38,19 +55,11 @@ function layoutDiv() { el += ''; el += ''; } - if (md_text(theme.sidebar.logo.title)) { - el += ''; - el += '
' + md_text(theme.sidebar.logo.title) + '
'; - if (config.subtitle) { - let arr = config.subtitle.split('|'); - if (arr.length > 0) { - el += '
' + arr[0] + '
'; - if (arr.length > 1) { - el += '
' + arr[1] + '
'; - } - } - } - el += '
'; + let main = md_text(theme.sidebar.logo.title); + if (main) { + let url = md_link(theme.sidebar.logo.title); + let sub = config.subtitle; + el += layoutTitle(main, url, sub); } } el += '
'; diff --git a/source/css/_layout/partial/footer.styl b/source/css/_layout/partial/footer.styl index 18b9fad..d1c4c0b 100644 --- a/source/css/_layout/partial/footer.styl +++ b/source/css/_layout/partial/footer.styl @@ -1,5 +1,5 @@ .page-footer - margin: 4rem 1rem 2rem + margin: 4rem 1rem color: var(--text-p3) a color: var(--text-p3) @@ -7,7 +7,7 @@ color: $color-hover .page-footer .sitemap - margin: .5rem 0 1.5rem + margin: .5rem 0 2rem display: grid grid-gap: 1rem 1rem grid-auto-flow: column dense diff --git a/source/css/_layout/sidebar/sidebar.styl b/source/css/_layout/sidebar/sidebar.styl index eb32330..ae98a91 100644 --- a/source/css/_layout/sidebar/sidebar.styl +++ b/source/css/_layout/sidebar/sidebar.styl @@ -81,8 +81,6 @@ .hover transform: translateY(0) opacity: 1 !important - a.avatar+a.title - txt-ellipsis() .logo-wrap.wiki