From d3c4f4eb83e262bfb01b29ab0d920ef3c9d7239e Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Wed, 26 Oct 2022 22:44:50 +0800 Subject: [PATCH] ghissues --- _config.yml | 4 +- _data/widgets.yml | 8 +++- layout/_partial/sidebar/widgets/ghissues.ejs | 46 ++++++++++++++++++++ layout/_partial/sidebar/widgets/ghrepo.ejs | 2 +- source/css/_layout/sidebar/ghrepo.styl | 17 +++++--- source/css/_layout/sidebar/widgets.styl | 18 ++++++++ source/css/_layout/tag-plugins/timeline.styl | 6 +-- 7 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 layout/_partial/sidebar/widgets/ghissues.ejs diff --git a/_config.yml b/_config.yml index 4618cf2..fefda22 100755 --- a/_config.yml +++ b/_config.yml @@ -27,8 +27,8 @@ sidebar: widgets: index: [welcome, recent, timeline] # 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: [toc, ghrepo, related] # for pages using 'layout:wiki' + post: [toc, ghrepo, ghissues] # for pages using 'layout:post' + wiki: [toc, ghrepo, ghissues, related] # for pages using 'layout:wiki' ######## Main ######## diff --git a/_data/widgets.yml b/_data/widgets.yml index 9ae11e9..6bb4cd7 100644 --- a/_data/widgets.yml +++ b/_data/widgets.yml @@ -3,13 +3,17 @@ # - markdown: 渲染 md 文本 # -# ---- 内置组件,暂时不支持覆盖 ---- ghrepo: layout: ghrepo related: layout: related -# ---- 默认组件,可以覆盖自定义配置 ---- +ghissues: + layout: ghissues + title: # Recent Issues + limit: 3 # 显示的issues最大数量 + labels: # 过滤只显示具有某些标签的issues + # 将其覆盖设置为空,可删除一个默认组件,例如 welcome: # Recent update recent: diff --git a/layout/_partial/sidebar/widgets/ghissues.ejs b/layout/_partial/sidebar/widgets/ghissues.ejs new file mode 100644 index 0000000..782574e --- /dev/null +++ b/layout/_partial/sidebar/widgets/ghissues.ejs @@ -0,0 +1,46 @@ +<% +function layoutDiv() { + var el = ''; + var repo; + var branch = 'main'; + if (page.layout === 'wiki' && page.wiki) { + let proj = theme.wiki.projects[page.wiki]; + if (proj && proj.repo) { + repo = proj.repo; + if (proj.branch != undefined) { + branch = proj.branch; + } + } + } else { + // 其它的如果有设置 repo 也可以 + repo = page.repo; + } + if (repo == undefined) { + return el; + } + item.api = 'https://api.github.com/repos/' + repo + '/issues?per_page=' + item.limit; + if (item.labels) { + item.api += '&labels=' + item.labels; + } + console.log(item.api); + el += '
'; + if (item.title) { + el += '
'; + el += '' + item.title + ''; + el += '
'; + } + el += '
'; + el += '
{ + if (item[key]) { + el += ' ' + key + '="' + item[key] + '"'; + } + }); + el += '>'; + el += '
'; + el += '
'; + el += '
'; + return el; +} +%> +<%- layoutDiv() %> diff --git a/layout/_partial/sidebar/widgets/ghrepo.ejs b/layout/_partial/sidebar/widgets/ghrepo.ejs index 3efa084..af1c13b 100644 --- a/layout/_partial/sidebar/widgets/ghrepo.ejs +++ b/layout/_partial/sidebar/widgets/ghrepo.ejs @@ -26,7 +26,7 @@ function layoutDiv() { el += ''; el += '
'; el += ''; - el += '' + repo + ''; + el += repo; el += '
'; el += '
 
'; el += '
'; diff --git a/source/css/_layout/sidebar/ghrepo.styl b/source/css/_layout/sidebar/ghrepo.styl index ae2c10a..32fbaf8 100644 --- a/source/css/_layout/sidebar/ghrepo.styl +++ b/source/css/_layout/sidebar/ghrepo.styl @@ -2,16 +2,19 @@ .widget-body a.repo display: block - border: 1px solid var(--block-border) + padding: 0.75rem 0.5rem color: var(--text-p2) background: var(--card) border-radius: $border-block - >div - margin: 0.5rem + box-shadow: $boxshadow-card + trans2 box-shadow transform + >div+div + margin-top: 0.5rem span color: var(--text-p2) &:hover - background: var(--block) + box-shadow: $boxshadow-card-float + transform: translateY(-1px) a.repo svg margin-right: 4px @@ -21,13 +24,13 @@ .repo-name font-size: $fs-14 font-weight: 700 - margin: 0.75rem 0.5rem + color: var(--text-p1) .repo-desc font-size: $fs-13 - margin: 0.75rem 0.5rem + margin-left: 2px + margin-right: 2px .grid font-size: $fs-13 - margin: 0.75rem 0.5rem display: grid grid-gap: 2px grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 2px) diff --git a/source/css/_layout/sidebar/widgets.styl b/source/css/_layout/sidebar/widgets.styl index 9e92040..e2286af 100644 --- a/source/css/_layout/sidebar/widgets.styl +++ b/source/css/_layout/sidebar/widgets.styl @@ -83,3 +83,21 @@ line-height: 1.5 &:hover color: $color-hover + + .widget-wrap#timeline .widget-body + margin-top: 0.5rem + .tag-plugin.timeline .timenode + .header + margin-bottom: 0.5rem + txt-ellipsis() + .user-info + background: var(--block) + &:hover + background: $color-hover + color: var(--card) + &:before + display: none + &+.timenode + margin-top: 0.75rem + .body + max-height: 40vh diff --git a/source/css/_layout/tag-plugins/timeline.styl b/source/css/_layout/tag-plugins/timeline.styl index 23d2c86..eef45bd 100644 --- a/source/css/_layout/tag-plugins/timeline.styl +++ b/source/css/_layout/tag-plugins/timeline.styl @@ -1,7 +1,7 @@ -.tag-plugin.folding .body:has(.timeline) +.md .tag-plugin.folding .body:has(.timeline) background: var(--site-bg) -.tag-plugin.timeline +.md .tag-plugin.timeline position: relative margin-top: 0 padding-left: 16px @@ -20,7 +20,7 @@ &:before display: none -.tag-plugin.timeline .timenode +.md .tag-plugin.timeline .timenode position: relative display: flex flex-direction: column