From 107be3d642cd0a32ee04ef9f00341a4f92731b7b Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Sat, 26 Jun 2021 15:02:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20wiki=20=E4=BE=A7=E8=BE=B9?= =?UTF-8?q?=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- languages/en.yml | 2 +- layout/_partial/sidebar/header.ejs | 27 ++++++-- layout/_partial/sidebar/logo.ejs | 66 ++++++++++++++---- layout/_partial/sidebar/widgets/toc.ejs | 16 ++--- layout/_partial/sidebar/widgets/wiki_more.ejs | 69 +++++++++++-------- source/css/_layout/md.styl | 2 +- source/css/_layout/partial/navbar.styl | 1 - source/css/_layout/partial/paginator.styl | 5 +- source/css/_layout/sidebar/footer.styl | 2 +- source/css/_layout/sidebar/sidebar.styl | 38 ++++++++-- source/css/_layout/sidebar/toc.styl | 2 + 11 files changed, 161 insertions(+), 69 deletions(-) diff --git a/languages/en.yml b/languages/en.yml index 28ec50d..8be7cde 100755 --- a/languages/en.yml +++ b/languages/en.yml @@ -3,7 +3,7 @@ btn: blog: Blog wiki: Wiki recent_publish: Recent - all_wiki: All + all_wiki: All Products category: Category categories: Categories tag: Tag diff --git a/layout/_partial/sidebar/header.ejs b/layout/_partial/sidebar/header.ejs index a226a62..bd38f17 100644 --- a/layout/_partial/sidebar/header.ejs +++ b/layout/_partial/sidebar/header.ejs @@ -1,6 +1,7 @@ <% function layoutMainMenu() { var el = ''; + el += partial('logo'); el += ''; return el; } +function layoutWikiMenu() { + var el = ''; + el += partial('logo'); + return el; +} +function layoutDiv() { + var el = ''; + el += '
'; + if (page.layout === 'wiki') { + el += layoutWikiMenu(); + } else { + el += layoutMainMenu(); + } + el += '
'; + return el; +} %> -
- <%- partial('logo') %> - <%- layoutMainMenu() %> -
+ +<%- layoutDiv() %> \ No newline at end of file diff --git a/layout/_partial/sidebar/logo.ejs b/layout/_partial/sidebar/logo.ejs index d31e53c..029304d 100644 --- a/layout/_partial/sidebar/logo.ejs +++ b/layout/_partial/sidebar/logo.ejs @@ -1,15 +1,51 @@ -
- <% if (md_text(theme.sidebar.logo.avatar)) { %> - - <% if (theme.style.animated_avatar.animate) { %> -
- <% } %> - -
- <% } %> - <% if (md_text(theme.sidebar.logo.title)) { %> - - <%- md_text(theme.sidebar.logo.title) %> - - <% } %> -
+<% +var wiki; +if (page.layout === 'wiki') { + site.pages.filter(function (p) { + return p.layout == 'wiki' && p.wiki == page.wiki && p.description + }).limit(1).each(function(p) { + wiki = p; + }); +} + +function layoutDiv() { + var el = ''; + if (page.layout === 'wiki') { + el += '
'; + // all products + el += ''; + el += ''; + el += __('btn.all_wiki'); + el += ''; + // this product + if (wiki === undefined) { + if (page.menu_id && theme.sidebar.menu[page.menu_id] && md_link(theme.sidebar.menu[page.menu_id])) { + wiki = new Object(); + wiki.path = md_link(theme.sidebar.menu[page.menu_id]); + wiki.wiki = __(md_text(theme.sidebar.menu[page.menu_id])); + } + } + if (wiki !== undefined) { + el += ''; + el += wiki.wiki; + el += ''; + } + } else { + el += '
'; + if (md_text(theme.sidebar.logo.avatar)) { + el += ''; + el += ''; + el += ''; + } + if (md_text(theme.sidebar.logo.title)) { + el += ''; + el += md_text(theme.sidebar.logo.title); + el += ''; + } + } + el += '
'; + return el; +} +%> + +<%- layoutDiv() %> \ No newline at end of file diff --git a/layout/_partial/sidebar/widgets/toc.ejs b/layout/_partial/sidebar/widgets/toc.ejs index d3be6c4..47bb122 100644 --- a/layout/_partial/sidebar/widgets/toc.ejs +++ b/layout/_partial/sidebar/widgets/toc.ejs @@ -25,15 +25,13 @@ function layoutDiv(fallback) { if (t.length > 0) { el += '
'; el += '
'; - el += ''; - if (page.toc_title) { - el += page.toc_title; - } else if (t == 'wiki') { - el += page.wiki || item.wiki; - } else { - el += __("meta.toc"); - } - el += ''; + if (page.toc_title) { + el += '' + page.toc_title + ''; + } else if (t == 'wiki') { + el += ''; + } else { + el += '' + __("meta.toc") + ''; + } el += '
'; el += '
'; if (page.layout == "wiki" && page.wiki) { diff --git a/layout/_partial/sidebar/widgets/wiki_more.ejs b/layout/_partial/sidebar/widgets/wiki_more.ejs index 8363684..a29257d 100644 --- a/layout/_partial/sidebar/widgets/wiki_more.ejs +++ b/layout/_partial/sidebar/widgets/wiki_more.ejs @@ -1,28 +1,41 @@ -<% if (page.layout == 'wiki') { %> - <% site.pages.filter(function (p) { %> - <% return p.layout == 'index' && p.title && p.wiki && p.wiki.includes(page.wiki) %> - <% }).limit(1).each(function(current_group) { %> - <% if (current_group.wiki.length > 1) { %> - - <% } %> - <% }); %> -<% } %> +<% +function layoutDiv() { + if (page.layout !== "wiki") { + return ''; + } + var current_group; + site.pages.filter(function (p) { + return p.layout == "index" && p.title && p.wiki && p.wiki.includes(page.wiki) + }).limit(1).each(function(p) { + current_group = p; + }); + if (current_group === undefined || current_group.wiki.length < 1) { + return ''; + } + var el = ''; + el += ''; + return el; +} +%> +<%- layoutDiv() %> diff --git a/source/css/_layout/md.styl b/source/css/_layout/md.styl index 47d8eb1..c1df589 100644 --- a/source/css/_layout/md.styl +++ b/source/css/_layout/md.styl @@ -78,7 +78,7 @@ article.md code font-size: 85% background: var(--block) padding: .2em .4em - border-radius: 2px + border-radius: 4px article.md pre -webkit-font-smoothing: auto -moz-osx-font-smoothing: auto diff --git a/source/css/_layout/partial/navbar.styl b/source/css/_layout/partial/navbar.styl index 90a4401..509c517 100644 --- a/source/css/_layout/partial/navbar.styl +++ b/source/css/_layout/partial/navbar.styl @@ -23,7 +23,6 @@ nav.cap &.active, &:hover background: var(--block-hover) color: var(--text-p1) - box-shadow: 0 0 4px 0px rgba(0, 0, 0, 0.1) @media screen and (max-width: $device-tablet) diff --git a/source/css/_layout/partial/paginator.styl b/source/css/_layout/partial/paginator.styl index ccedb1e..ccced78 100644 --- a/source/css/_layout/partial/paginator.styl +++ b/source/css/_layout/partial/paginator.styl @@ -18,9 +18,9 @@ color: var(--text-p3) padding: 1rem line-height: 0 + filter: grayscale(100%) img height: 1rem - filter: grayscale(100%) &.disable pointer-events: none opacity: 0.25 @@ -30,5 +30,4 @@ border-left: 1px solid var(--block-border) a.paginator:hover background: var(--card) - img - filter: grayscale(0%) + filter: unset diff --git a/source/css/_layout/sidebar/footer.styl b/source/css/_layout/sidebar/footer.styl index 228837d..6af1ba2 100644 --- a/source/css/_layout/sidebar/footer.styl +++ b/source/css/_layout/sidebar/footer.styl @@ -20,7 +20,7 @@ &:hover color: $color-hover z-index: 1 - filter: grayscale(0%) + filter: unset transform: translateY(-1px) background: linear-gradient(145deg, #ddd, #fff) box-shadow: 2px 4px 8px #ddd, -2px -4px 8px #fff diff --git a/source/css/_layout/sidebar/sidebar.styl b/source/css/_layout/sidebar/sidebar.styl index cdef169..ed2a751 100644 --- a/source/css/_layout/sidebar/sidebar.styl +++ b/source/css/_layout/sidebar/sidebar.styl @@ -9,7 +9,7 @@ height: "calc(100% - 2 * %s)" % var(--gap-l) .logo-wrap - margin: 1rem 0 + margin: 1rem 0 .5rem display: flex align-items: center color: var(--text-p0) @@ -59,17 +59,30 @@ animation: spin infinite 1s animation-timing-function: linear - - .title font-size: 1.75rem font-weight: 900 color: inherit line-height: 1; font-family: $ff-logo + + +.logo-wrap.wiki + flex-direction: column + align-items: flex-start + a.wiki-home + margin-bottom: .5rem + color: var(--text-p2) + img + height: .9em + margin-right: .5rem + &:hover + color: $color-hover + filter: unset !important + nav.menu - margin-top: 0 + margin: 1rem 0 .5rem background: var(--block) border-radius: 6px display: flex @@ -120,6 +133,8 @@ nav.menu background: var(--site-bg) padding: 2px 0 z-index 1 + &:empty + display: none .cap-action hover-block 4px 4px line-height: 0 @@ -140,7 +155,7 @@ nav.menu margin-bottom: 0.5em >a:hover text-decoration: underline - .widget-wrap#recent .widget-body + .widget-wrap#recent .widget-body, .widget-wrap#related .widget-body border: 1px solid var(--block-border) border-radius: $border-block background: var(--block) @@ -163,4 +178,15 @@ nav.menu &:hover color: $color-hover background: var(--card) - + &.wiki + font-weight: 700 + div.excerpt + margin-top: .5rem + color: var(--text-p3) + font-size: $fs-12 + font-weight: 400 + display: -webkit-box + -webkit-box-orient: vertical + overflow: hidden + -webkit-line-clamp: 3 + diff --git a/source/css/_layout/sidebar/toc.styl b/source/css/_layout/sidebar/toc.styl index a4ec70e..11e8a56 100644 --- a/source/css/_layout/sidebar/toc.styl +++ b/source/css/_layout/sidebar/toc.styl @@ -65,6 +65,8 @@ border-bottom-right-radius: 4px font-size: $fs-12 font-weight: 500 + position sticky + top: 0 &.active color: var(--text-p2) font-size: $fs-14