This commit is contained in:
xaoxuu 2022-10-22 13:03:47 +08:00
parent a285e517ee
commit 7a742d61fe
13 changed files with 89 additions and 48 deletions

View File

@ -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 ########

View File

@ -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:

View File

@ -1,27 +1,4 @@
<%
function layoutMenu() {
var el = '';
el += '<nav class="menu dis-select';
if (where == 'main') {
el += ' mobile-hidden';
}
el += '">';
for (let id of Object.keys(theme.sidebar.menu)) {
let item = theme.sidebar.menu[id];
if (item == undefined || item.length == 0) {
continue;
}
el += '<a class="nav-item';
if (id == page.menu_id) {
el += ' active';
}
el += '" href="' + url_for(md_link(item)) + '">';
el += __(md_text(item));
el += '</a>';
}
el += '</nav>';
return el;
}
function layoutDiv() {
var el = '';
el += '<header class="header';
@ -33,13 +10,12 @@ function layoutDiv() {
if (where != 'main') {
if (page.layout === 'wiki' && page.wiki) {
if (page.menu_id !== 'wiki') {
el += layoutMenu();
el += partial('menu', {where: where});
}
} else {
el += layoutMenu();
el += partial('menu', {where: where});
}
}
el += '</header>';
return el;
}

View File

@ -0,0 +1,27 @@
<%
function layoutDiv() {
var el = '';
el += '<nav class="menu dis-select';
if (where == 'main') {
el += ' mobile-hidden';
}
el += '">';
for (let id of Object.keys(theme.sidebar.menu)) {
let item = theme.sidebar.menu[id];
if (item == undefined || item.length == 0) {
continue;
}
el += '<a class="nav-item';
if (id == page.menu_id) {
el += ' active';
}
el += '" href="' + url_for(md_link(item)) + '">';
el += __(md_text(item));
el += '</a>';
}
el += '</nav>';
return el;
}
%>
<%- layoutDiv() %>

View File

@ -38,9 +38,9 @@ function layoutDiv() {
el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg>';
el += '<span type="text" id="forks_count"></span>';
el += '</div>';
el += '<div class="flex-row stellar-ghinfo-api" api="https://api.github.xaoxuu.com/repos/' + repo + '/releases/latest">';
el += '<div class="flex-row stellar-ghinfo-api" index="0" api="https://api.github.xaoxuu.com/repos/' + repo + '/tags">';
el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"></path></svg>';
el += '<span type="text" id="tag_name"></span>';
el += '<span type="text" id="latest-tag-name">0</span>';
el += '</div>';
el += '</div>';
el += '</a>';

View File

@ -45,6 +45,10 @@ function layoutDiv() {
el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>';
el += 'Follow';
el += '</a>';
// menu
if (item.menu) {
el += partial('../menu', {where: 'sidebar'});
}
el += '</div>';
el += '</div>';
return el;

View File

@ -15,11 +15,7 @@ function layoutToc() {
function layoutTocHeader(title) {
var el = '';
el += '<div class="widget-header cap dis-select">';
if (title) {
el += '<span class="name">' + title + '</span>';
} else {
el += '<span class="name">' + __("meta.toc") + '</span>';
}
el += '<span class="name">' + (title || page.title || __("meta.toc")) + '</span>';
el += '</div>';
return el;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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() {
});
},