From 966e41f7a7cf8b87294448314dac722cedad270d Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Wed, 5 Oct 2022 23:00:52 +0800 Subject: [PATCH] ghuser --- _config.yml | 5 ++ layout/404.ejs | 2 +- layout/_partial/main/header/index.ejs | 2 +- layout/_partial/sidebar/index.ejs | 4 +- layout/_partial/sidebar/widgets/ghuser.ejs | 49 +++++++++++++++ layout/post.ejs | 2 +- layout/wiki.ejs | 2 +- source/css/_common/base.styl | 2 - source/css/_common/button.styl | 2 +- source/css/_layout/partial/related.styl | 2 + source/css/_layout/sidebar/ghuser.styl | 71 ++++++++++++++++++++++ source/css/_layout/sidebar/repo_info.styl | 3 + source/css/_layout/tag-plugins/about.styl | 3 +- source/css/_layout/tag-plugins/common.styl | 2 +- source/js/plugins/ghinfo.js | 1 + 15 files changed, 141 insertions(+), 11 deletions(-) create mode 100644 layout/_partial/sidebar/widgets/ghuser.ejs create mode 100644 source/css/_layout/sidebar/ghuser.styl diff --git a/_config.yml b/_config.yml index a850039..eb658de 100755 --- a/_config.yml +++ b/_config.yml @@ -42,6 +42,11 @@ sidebar: min_depth: 2 max_depth: 5 fallback: recent # Use a backup widget when toc does not exist. + # github user info + ghuser: + layout: ghuser + api: https://api.github.com + username: # your github login username # welcome welcome: layout: markdown diff --git a/layout/404.ejs b/layout/404.ejs index ad50f7a..7789dc7 100755 --- a/layout/404.ejs +++ b/layout/404.ejs @@ -2,7 +2,7 @@ page.menu_id = '404'; page.layout = '404'; page.comment_title = ''; -page.header = false; +page.header = 'auto'; page.robots = 'none'; %>
diff --git a/layout/_partial/main/header/index.ejs b/layout/_partial/main/header/index.ejs index 3b1c886..ee9e064 100644 --- a/layout/_partial/main/header/index.ejs +++ b/layout/_partial/main/header/index.ejs @@ -1,3 +1,3 @@ -<% if (page.header != false) { %> +<% if (page.header != 'auto' && page.header != false) { %> <%- partial('../../sidebar/header', {where: 'main'}) %> <% } %> diff --git a/layout/_partial/sidebar/index.ejs b/layout/_partial/sidebar/index.ejs index bf2bece..e016719 100755 --- a/layout/_partial/sidebar/index.ejs +++ b/layout/_partial/sidebar/index.ejs @@ -69,6 +69,8 @@ function layoutFooterDiv() { } } %> -<%- partial('header', {where: 'sidebar'}) %> +<% if (page.header == undefined || page.header == 'left' || page.header == 'auto') { %> + <%- partial('header', {where: 'sidebar'}) %> +<% } %> <%- layoutWidgets() %> <%- layoutFooterDiv() %> diff --git a/layout/_partial/sidebar/widgets/ghuser.ejs b/layout/_partial/sidebar/widgets/ghuser.ejs new file mode 100644 index 0000000..8e459ff --- /dev/null +++ b/layout/_partial/sidebar/widgets/ghuser.ejs @@ -0,0 +1,49 @@ +<% +var btns = []; +btns.push({ + key: 'followers', + desc: 'followers' +}); +btns.push({ + key: 'following', + desc: 'following' +}); +btns.push({ + key: 'public_repos', + desc: 'repos' +}); + +function layoutDiv() { + var el = ''; + if (item.username == undefined || item.username.length == 0) { + return el; + } + + el += '
'; + el += '
'; + el += ''; + // username + el += '
'; + el += item.username; + el += '
'; + el += '

'; + + el += '
'; + btns.forEach((btn, i) => { + el += ''; + el += ''; + el += '' + btn.desc + ''; + el += ''; + }); + el += '
'; + // follow + el += ''; + el += '
'; + el += '
'; + return el; +} +%> +<%- layoutDiv() %> diff --git a/layout/post.ejs b/layout/post.ejs index 9f9711c..dc0233a 100755 --- a/layout/post.ejs +++ b/layout/post.ejs @@ -3,7 +3,7 @@ if (page.menu_id == undefined) { page.menu_id = 'post'; } if (page.header == undefined) { - page.header = false; + page.header = 'auto'; } function layoutTitle() { const title = page.h1 || page.title; diff --git a/layout/wiki.ejs b/layout/wiki.ejs index 591713e..f0bb3f3 100755 --- a/layout/wiki.ejs +++ b/layout/wiki.ejs @@ -26,7 +26,7 @@ function layoutTitle() { <% } else { %> <% if (page.header == undefined) { - page.header = false; + page.header = 'auto'; } %> <%- partial('_partial/main/navbar/breadcrumb') %> diff --git a/source/css/_common/base.styl b/source/css/_common/base.styl index 0789201..4aeb966 100644 --- a/source/css/_common/base.styl +++ b/source/css/_common/base.styl @@ -34,8 +34,6 @@ p:not([class]), li:not([class]) color: $color-link // color: darken($color-hover, 10) // background: alpha($color-hover, 0.08) - &:before - opacity: 0 &:after height: 100% opacity: 0.2 diff --git a/source/css/_common/button.styl b/source/css/_common/button.styl index 082f98d..56dbe4c 100644 --- a/source/css/_common/button.styl +++ b/source/css/_common/button.styl @@ -14,7 +14,7 @@ a.button font-size: $fs-15 &.theme background: $color-theme - color: var(--site-bg) + color: var(--card) &:hover background: $color-hover diff --git a/source/css/_layout/partial/related.styl b/source/css/_layout/partial/related.styl index da2ea84..b3ac680 100644 --- a/source/css/_layout/partial/related.styl +++ b/source/css/_layout/partial/related.styl @@ -131,6 +131,8 @@ text-decoration: underline &:hover color: $color-hover + &:after + display: none div.cmt-body min-height: 150px position: relative diff --git a/source/css/_layout/sidebar/ghuser.styl b/source/css/_layout/sidebar/ghuser.styl new file mode 100644 index 0000000..220e866 --- /dev/null +++ b/source/css/_layout/sidebar/ghuser.styl @@ -0,0 +1,71 @@ +.widget-wrap#github-user .widget-body + display: flex + flex-direction: column + align-items: center + background: var(--card) + border-radius: $border-card + padding: 1rem + margin: 'calc(%s + 1.25rem)' % var(--gap-p) 0 + +.widget-wrap#github-user .widget-body .avatar + display: block + border-radius: 100% + max-width: 80% + margin-top: 1.5rem + +.widget-wrap#github-user .widget-body .username + font-weight: 900 + font-size: $fs-h2 + margin-top: 1.5rem + color: var(--text-p0) + +.widget-wrap#github-user .widget-body .follow + font-weight: 500 + border-radius: 64px + padding: 0.5rem 1rem + background: $color-theme + color: var(--card) + font-size: 1rem + align-self: stretch + text-align: center + line-height: 1.5 + display: flex + align-items: center + justify-content: center + trans1: background + svg + margin-right: 4px + &:hover + background: $color-hover + + + +.widget-wrap#github-user .widget-body .buttons + margin: 0.75rem 0 + align-self: stretch + display: grid + grid-gap: 2px + grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 2px) + +.widget-wrap#github-user .widget-body .btn + display: flex + flex-direction: column + align-items: center + color: inherit + border: 1px solid transparent + border-radius: 4px + padding: 0.25rem 0 + trans1: background + &:hover + background: var(--block) + + +.widget-wrap#github-user .widget-body .buttons .btn .title + font-size: 1rem + font-weight: 700 + + +.widget-wrap#github-user .widget-body .buttons .btn .desc + font-size: $fs-12 + color: var(--text-p3) + font-weight: 500 \ No newline at end of file diff --git a/source/css/_layout/sidebar/repo_info.styl b/source/css/_layout/sidebar/repo_info.styl index c48b268..d3cfc9d 100644 --- a/source/css/_layout/sidebar/repo_info.styl +++ b/source/css/_layout/sidebar/repo_info.styl @@ -24,5 +24,8 @@ width: 1em height: 1em margin-left: 4px + div + display: flex + align-items: center a:hover background: var(--block-hover) diff --git a/source/css/_layout/tag-plugins/about.styl b/source/css/_layout/tag-plugins/about.styl index 3575008..65f396e 100644 --- a/source/css/_layout/tag-plugins/about.styl +++ b/source/css/_layout/tag-plugins/about.styl @@ -1,10 +1,9 @@ .tag-plugin.about background: var(--block) border-radius: $border-block - padding: 2rem + padding: 3rem 2rem 2rem .about-header display flex - flex-direction: row-reverse justify-content: space-between flex-wrap: wrap img diff --git a/source/css/_layout/tag-plugins/common.styl b/source/css/_layout/tag-plugins/common.styl index 6343193..3b90149 100644 --- a/source/css/_layout/tag-plugins/common.styl +++ b/source/css/_layout/tag-plugins/common.styl @@ -81,7 +81,7 @@ if hexo-config('style.darkmode') == 'auto' .tag-plugin[color='light'] --theme-border: white --theme-bg: #ddd - color: var(--site-bg) !important + color: var(--card) !important .tag-plugin[color='dark'] --theme-border: black diff --git a/source/js/plugins/ghinfo.js b/source/js/plugins/ghinfo.js index 1530402..485afbe 100644 --- a/source/js/plugins/ghinfo.js +++ b/source/js/plugins/ghinfo.js @@ -49,6 +49,7 @@ const GitHubInfo = { 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]); } }, function() { });