diff --git a/_config.yml b/_config.yml index f3a7f0f..ae2ab46 100755 --- a/_config.yml +++ b/_config.yml @@ -27,8 +27,8 @@ sidebar: widgets: index: [welcome, recent] # for home/wiki/categories/tags/archives/404 pages page: [welcome, toc] # for pages using 'layout:page' - post: [toc, repo_info] # for pages using 'layout:post' - wiki: [toc, repo_info, wiki_more] # for pages using 'layout:wiki' + post: [toc, ghrepo] # for pages using 'layout:post' + wiki: [ghrepo, toc, wiki_more] # for pages using 'layout:wiki' ######## Main ######## diff --git a/_data/widgets.yml b/_data/widgets.yml index 3b95466..9032115 100644 --- a/_data/widgets.yml +++ b/_data/widgets.yml @@ -3,9 +3,9 @@ # - markdown: 渲染 md 文本 # -# ---- 内置组件,请勿覆盖 ---- -repo_info: - layout: repo_info +# ---- 内置组件,暂时不支持覆盖 ---- +ghrepo: + layout: ghrepo wiki_more: layout: wiki_more diff --git a/languages/en.yml b/languages/en.yml index 30b9039..adc51da 100755 --- a/languages/en.yml +++ b/languages/en.yml @@ -28,7 +28,6 @@ meta: updated: 'Updated on' license: License share: Share - repo_info: Repo Info date_suffix: just: Just min: minutes ago diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index b393eab..2b2b8ab 100755 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -28,7 +28,6 @@ meta: updated: 更新于 license: 许可协议 share: 分享文章 - repo_info: 项目仓库 date_suffix: just: 刚刚 min: 分钟前 diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index 0d06206..bc1f210 100755 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -28,7 +28,6 @@ meta: updated: 更新於 license: 授權條款 share: 分享文章 - repo_info: 專案儲存庫 date_suffix: just: 剛剛 min: 分鐘前 diff --git a/layout/_partial/sidebar/widgets/ghrepo.ejs b/layout/_partial/sidebar/widgets/ghrepo.ejs new file mode 100644 index 0000000..f8cf153 --- /dev/null +++ b/layout/_partial/sidebar/widgets/ghrepo.ejs @@ -0,0 +1,53 @@ +<% +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; + } + // 布局 + el += '
'; + // body + el += '
'; + el += ''; + el += '
'; + el += '
'; + return el; +} +%> +<%- layoutDiv() %> diff --git a/layout/_partial/sidebar/widgets/repo_info.ejs b/layout/_partial/sidebar/widgets/repo_info.ejs deleted file mode 100644 index 95e0453..0000000 --- a/layout/_partial/sidebar/widgets/repo_info.ejs +++ /dev/null @@ -1,91 +0,0 @@ -<% -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; - } - // 布局 - el += '
'; - // header - el += '
'; - el += '' + __("meta.repo_info") + ''; - el += '
'; - // body - el += '
'; - el += '
'; - var items = []; - // GitHub - items.push({ - icon: '', - text: 'GitHub', - href: 'https://github.com/' + repo - }); - // Stars - items.push({ - icon: '', - text: 'Stars', - apiKey: 'stargazers_count', - href: 'https://github.com/' + repo + '/stargazers' - }); - // Forks - items.push({ - icon: '', - text: 'Forks', - apiKey: 'forks_count', - href: 'https://github.com/' + repo + '/network/members' - }); - // Releases - items.push({ - icon: '', - text: 'Releases', - href: 'https://github.com/' + repo + '/releases' - }); - // Download - items.push({ - icon: '', - text: 'Download Zip', - href: 'https://github.com/' + repo + '/archive/refs/heads/' + branch + '.zip' - }); - items.forEach((item, i) => { - el += '
'; - el += ''; - el += '
'; - // right - el += '
'; - if (item.apiKey) { - el += ''; - } - if (item.icon) { - el += item.icon; - } - el += '
'; - el += '
'; - }); - el += '
'; - el += '
'; - el += ''; - return el; -} -%> -<%- layoutDiv() %> diff --git a/source/css/_layout/sidebar/ghrepo.styl b/source/css/_layout/sidebar/ghrepo.styl new file mode 100644 index 0000000..221a4bb --- /dev/null +++ b/source/css/_layout/sidebar/ghrepo.styl @@ -0,0 +1,30 @@ +.widget-wrap#repo-info + .widget-body + a.repo + display: block + border: 1px solid var(--block-border) + color: var(--text-p2) + background: var(--block) + border-radius: $border-block + >div + margin: 0.75rem 0.5rem + span + color: var(--text-p2) + &:hover + background: var(--block-hover) + a.repo + svg + margin-right: 4px + .flex-row + display: flex + align-items: center + .repo-name + font-size: $fs-14 + font-weight: 700 + .repo-desc + font-size: $fs-13 + .grid + font-size: $fs-13 + display: grid + grid-gap: 2px + grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 2px) diff --git a/source/css/_layout/sidebar/repo_info.styl b/source/css/_layout/sidebar/repo_info.styl deleted file mode 100644 index d3cfc9d..0000000 --- a/source/css/_layout/sidebar/repo_info.styl +++ /dev/null @@ -1,31 +0,0 @@ -.widget-wrap#repo-info - .widget-body - >.items - margin: 4px 0 - border: 1px solid var(--block-border) - border-radius: $border-block - background: var(--block) - overflow: hidden - .line - margin: 0 - height: 1px - background: var(--block-border) - &+.line,&:first-child,&:last-child - display: none - a.item-link - color: var(--text-p2) - font-weight: 500 - display: flex - align-items: center - padding: 0.5rem .5rem - font-size: $fs-13 - justify-content: space-between - svg - width: 1em - height: 1em - margin-left: 4px - div - display: flex - align-items: center - a:hover - background: var(--block-hover)