hexo-theme-stellar/layout/_partial/sidebar/widgets/repo_info.ejs

65 lines
3.6 KiB
Plaintext
Raw Normal View History

2021-07-04 22:53:55 +08:00
<%
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 += '<div class="widget-wrap" id="repo-info">';
el += '<div class="widget-body fs14">';
var items = [];
// Readme
items.push({
icon: '<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="M0 1.75A.75.75 0 01.75 1h4.253c1.227 0 2.317.59 3 1.501A3.744 3.744 0 0111.006 1h4.245a.75.75 0 01.75.75v10.5a.75.75 0 01-.75.75h-4.507a2.25 2.25 0 00-1.591.659l-.622.621a.75.75 0 01-1.06 0l-.622-.621A2.25 2.25 0 005.258 13H.75a.75.75 0 01-.75-.75V1.75zm8.755 3a2.25 2.25 0 012.25-2.25H14.5v9h-3.757c-.71 0-1.4.201-1.992.572l.004-7.322zm-1.504 7.324l.004-5.073-.002-2.253A2.25 2.25 0 005.003 2.5H1.5v9h3.757a3.75 3.75 0 011.994.574z"></path></svg>',
text: 'Readme',
href: 'https://github.com/' + repo + '#readme'
});
// Releases
items.push({
icon: '<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="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>',
text: 'Releases',
href: 'https://github.com/' + repo + '/releases'
});
// Download
items.push({
icon: '<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="M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"></path></svg>',
text: 'Download',
href: 'https://github.com/' + repo + '/archive/refs/heads/' + branch + '.zip'
});
// Issues
items.push({
icon: '<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 d="M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path><path fill-rule="evenodd" d="M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"></path></svg>',
text: 'Issues',
href: 'https://github.com/' + repo + '/issues'
});
items.forEach((item, i) => {
el += '<div class="item"><a class="item-link"';
el += ' title="' + item.href + '"';
el += ' href="' + url_for(item.href) + '"';
el += ' target="_blank" rel="external nofollow noopener noreferrer"';
el += '>';
el += item.icon;
2021-07-07 01:18:13 +08:00
el += '<span>' + item.text + '</span>';
2021-07-04 22:53:55 +08:00
el += '</a></div>';
});
el += '</div>';
el += '</div>';
return el;
}
%>
<%- layoutDiv() %>