From 7a742d61fe26857411d50207f407b397af630da0 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Sat, 22 Oct 2022 13:03:47 +0800 Subject: [PATCH] update --- _config.yml | 2 +- _data/widgets.yml | 3 ++- layout/_partial/sidebar/header.ejs | 28 ++-------------------- layout/_partial/sidebar/menu.ejs | 27 +++++++++++++++++++++ layout/_partial/sidebar/widgets/ghrepo.ejs | 4 ++-- layout/_partial/sidebar/widgets/ghuser.ejs | 4 ++++ layout/_partial/sidebar/widgets/toc.ejs | 6 +---- source/css/_layout/list.styl | 5 ++++ source/css/_layout/sidebar/ghrepo.styl | 8 ++++--- source/css/_layout/sidebar/ghuser.styl | 16 ++++++++++++- source/css/_layout/sidebar/sidebar.styl | 10 ++++---- source/css/_layout/sidebar/toc_common.styl | 8 ++++--- source/js/plugins/ghinfo.js | 16 +++++++++++-- 13 files changed, 89 insertions(+), 48 deletions(-) create mode 100644 layout/_partial/sidebar/menu.ejs diff --git a/_config.yml b/_config.yml index 66bc7a2..a8bed11 100755 --- a/_config.yml +++ b/_config.yml @@ -28,7 +28,7 @@ sidebar: index: [welcome, recent] # for home/wiki/categories/tags/archives/404 pages page: [welcome, toc] # for pages using 'layout:page' post: [toc, ghrepo] # for pages using 'layout:post' - wiki: [ghrepo, toc, wiki_more] # for pages using 'layout:wiki' + wiki: [toc, ghrepo, wiki_more] # for pages using 'layout:wiki' ######## Main ######## diff --git a/_data/widgets.yml b/_data/widgets.yml index 9032115..5ed9a5a 100644 --- a/_data/widgets.yml +++ b/_data/widgets.yml @@ -28,7 +28,8 @@ ghuser: layout: ghuser api: https://api.github.com username: github # your github login username - avatar: true # true / false + avatar: true # show avatar or not + menu: true # show menu or not welcome: diff --git a/layout/_partial/sidebar/header.ejs b/layout/_partial/sidebar/header.ejs index c0278e6..6b51076 100644 --- a/layout/_partial/sidebar/header.ejs +++ b/layout/_partial/sidebar/header.ejs @@ -1,27 +1,4 @@ <% -function layoutMenu() { - var el = ''; - el += ''; - return el; -} function layoutDiv() { var el = ''; el += '
'; + el += __(md_text(item)); + el += ''; + } + el += ''; + return el; +} +%> + +<%- layoutDiv() %> diff --git a/layout/_partial/sidebar/widgets/ghrepo.ejs b/layout/_partial/sidebar/widgets/ghrepo.ejs index f8cf153..3efa084 100644 --- a/layout/_partial/sidebar/widgets/ghrepo.ejs +++ b/layout/_partial/sidebar/widgets/ghrepo.ejs @@ -38,9 +38,9 @@ function layoutDiv() { el += ''; el += ''; el += ''; - el += '
'; + el += '
'; el += ''; - el += ''; + el += '0'; el += '
'; el += '
'; el += ''; diff --git a/layout/_partial/sidebar/widgets/ghuser.ejs b/layout/_partial/sidebar/widgets/ghuser.ejs index ab524d3..24351b4 100644 --- a/layout/_partial/sidebar/widgets/ghuser.ejs +++ b/layout/_partial/sidebar/widgets/ghuser.ejs @@ -45,6 +45,10 @@ function layoutDiv() { el += ''; el += 'Follow'; el += ''; + // menu + if (item.menu) { + el += partial('../menu', {where: 'sidebar'}); + } el += ''; el += ''; return el; diff --git a/layout/_partial/sidebar/widgets/toc.ejs b/layout/_partial/sidebar/widgets/toc.ejs index 641089e..a0d9302 100644 --- a/layout/_partial/sidebar/widgets/toc.ejs +++ b/layout/_partial/sidebar/widgets/toc.ejs @@ -15,11 +15,7 @@ function layoutToc() { function layoutTocHeader(title) { var el = ''; el += '
'; - if (title) { - el += '' + title + ''; - } else { - el += '' + __("meta.toc") + ''; - } + el += '' + (title || page.title || __("meta.toc")) + ''; el += '
'; return el; } diff --git a/source/css/_layout/list.styl b/source/css/_layout/list.styl index 93f9d12..4a5d4d4 100644 --- a/source/css/_layout/list.styl +++ b/source/css/_layout/list.styl @@ -1,6 +1,10 @@ // list .post-list margin: 1rem + .post-title + margin-top: 1.5rem + .post-title:first-child + margin-top: .5rem // card .post-list .post-card @@ -51,6 +55,7 @@ margin-left: -1rem margin-top: -1rem margin-right: -1rem + background: var(--block) &:not(.lazy) trans1: transform 1s img diff --git a/source/css/_layout/sidebar/ghrepo.styl b/source/css/_layout/sidebar/ghrepo.styl index 221a4bb..691545e 100644 --- a/source/css/_layout/sidebar/ghrepo.styl +++ b/source/css/_layout/sidebar/ghrepo.styl @@ -4,14 +4,14 @@ display: block border: 1px solid var(--block-border) color: var(--text-p2) - background: var(--block) + background: var(--card) border-radius: $border-block >div - margin: 0.75rem 0.5rem + margin: 0.5rem span color: var(--text-p2) &:hover - background: var(--block-hover) + background: var(--block) a.repo svg margin-right: 4px @@ -21,8 +21,10 @@ .repo-name font-size: $fs-14 font-weight: 700 + margin: 0.75rem 0.5rem .repo-desc font-size: $fs-13 + margin: 0.75rem 0.5rem .grid font-size: $fs-13 display: grid diff --git a/source/css/_layout/sidebar/ghuser.styl b/source/css/_layout/sidebar/ghuser.styl index fd927d4..0dc7d02 100644 --- a/source/css/_layout/sidebar/ghuser.styl +++ b/source/css/_layout/sidebar/ghuser.styl @@ -47,7 +47,21 @@ &:hover background: $color-hover - +.widget-wrap#github-user .widget-body .menu + margin-bottom: 0 + background: none + a.active + box-shadow: none + position: relative + &:after + content: '' + position: absolute + height: 3px + bottom: 0 + width: 32px + left: 'calc(50% - 0.5 * %s)' % @width + border-radius: 4px + background: $color-theme .widget-wrap#github-user .widget-body .buttons margin: 1rem 0 diff --git a/source/css/_layout/sidebar/sidebar.styl b/source/css/_layout/sidebar/sidebar.styl index 6d3759a..36423d0 100644 --- a/source/css/_layout/sidebar/sidebar.styl +++ b/source/css/_layout/sidebar/sidebar.styl @@ -134,7 +134,7 @@ nav.menu font-size: $fs-14 font-weight: 500 overflow: hidden - padding: 0.375rem 0.75rem + padding: 0.375rem 0.5rem color: var(--text-p3) text-align: center &.active, &:hover @@ -151,6 +151,7 @@ nav.menu scrollbar-width: none scrollbar(0, 0) z-index: 1 + line-height: 1.2 .widget-wrap margin: 1rem 0 3rem 0 .widget-header @@ -159,14 +160,15 @@ nav.menu align-items: center font-weight: 500 position: sticky - position: -webkit-sticky top: -2px background: var(--site-bg) padding-top: 2px z-index 1 - line-height: 2 - color: var(--text-p4) + color: var(--text-p3) font-size: $fs-14 + >span + margin: 0.25rem 0 + text-align: left &:empty display: none .cap-action diff --git a/source/css/_layout/sidebar/toc_common.styl b/source/css/_layout/sidebar/toc_common.styl index 524c980..de30de4 100644 --- a/source/css/_layout/sidebar/toc_common.styl +++ b/source/css/_layout/sidebar/toc_common.styl @@ -1,8 +1,10 @@ -.widget-wrap#toc .widget-header - line-height: 2.4 +.widget-wrap.single#toc .widget-header + font-weight: 500 + font-size: $fs-12 + >span + margin: 0.5rem 0 #toc .widget-body - line-height: 1.2 margin-top: 0 ul ul, ul ol padding-left: 0 diff --git a/source/js/plugins/ghinfo.js b/source/js/plugins/ghinfo.js index d5fd027..2642853 100644 --- a/source/js/plugins/ghinfo.js +++ b/source/js/plugins/ghinfo.js @@ -44,13 +44,25 @@ const GitHubInfo = { }, layout: (cfg) => { const el = $(cfg.el)[0]; - GitHubInfo.requestAPI(cfg.api, function(data) { - const arr = data.content || data; + function fill(data) { for (let key of Object.keys(data)) { $(el).find("[type=text]#" + key).text(data[key]); $(el).find("[type=link]#" + key).attr("href", data[key]); $(el).find("[type=img]#" + key).attr("src", data[key]); } + } + GitHubInfo.requestAPI(cfg.api, function(data) { + const idx = el.getAttribute('index'); + if (idx != undefined) { + const arr = data.content || data; + if (arr && arr.length > idx) { + let obj = arr[idx]; + obj['latest-tag-name'] = obj['name']; + fill(arr[idx]); + } + } else { + fill(data); + } }, function() { }); },