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

71 lines
3.9 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">';
2021-07-14 14:54:06 +08:00
// header
el += '<div class="widget-header cap dis-select">';
el += '<span class="name">' + __("meta.repo_info") + '</span>';
el += '</div>';
// body
2021-07-04 22:53:55 +08:00
el += '<div class="widget-body fs14">';
var items = [];
2021-07-14 14:54:06 +08:00
// GitHub
2021-07-04 22:53:55 +08:00
items.push({
2021-07-14 14:54:06 +08:00
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="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>',
text: 'GitHub',
href: 'https://github.com/' + repo
2021-07-04 22:53:55 +08:00
});
// 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) => {
2021-07-14 14:54:06 +08:00
el += '<div class="line"></div>';
el += '<a class="item-link"';
2021-07-04 22:53:55 +08:00
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-14 14:54:06 +08:00
el += '</a>';
2021-07-04 22:53:55 +08:00
});
el += '</div>';
el += '</div>';
return el;
}
%>
<%- layoutDiv() %>