This commit is contained in:
xaoxuu 2021-02-27 22:27:56 +08:00
parent 984aaa6c77
commit 034632e83c
1 changed files with 12 additions and 9 deletions

View File

@ -12,18 +12,21 @@
const { ArgsMap } = require('./utils'); const { ArgsMap } = require('./utils');
hexo.extend.tag.register('copy', function(args) { hexo.extend.tag.register('copy', function(args) {
args = ArgsMap(args, ['width'], ['text', 'more']); args = ArgsMap(args, ['width', 'git'], ['text']);
var text; if (args == undefined || args.text == undefined) {
if (args.text == 'git' && args.more && args.more.length > 0) { return '';
text = args.more; }
var text = args.text;
if (args.git) {
if (text.substr(0,1) == '/') { if (text.substr(0,1) == '/') {
text = text.substring(1); text = text.substring(1);
} }
text = 'https://github.com/' + text + '.git'; if (args.git == 'ssh') {
} else if (args.text && args.text.length > 0) { text = 'git@github.com:' + text + '.git';
text = args.text; } else if (args.git == 'gh') {
if (args.more && args.more.length > 0) { text = 'gh repo clone ' + text;
text += ' ' + args.more; } else {
text = 'https://github.com/' + text + '.git';
} }
} }
function generate_id(text) { function generate_id(text) {