You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
727 B
31 lines
727 B
'use strict'; |
|
|
|
function postBtn(args) { |
|
args = args.join(' ').split(',') |
|
let cls = args[0].trim() |
|
let icon = '' |
|
let text = '' |
|
let url = '' |
|
if (args[1].indexOf('fas') > -1) { |
|
icon = args[1].trim() |
|
text = args[2].trim() |
|
url = args[3] || '' |
|
} else { |
|
text = args[1].trim() |
|
url = args[2] || '' |
|
} |
|
url = url.trim() |
|
if (url.length > 0) { |
|
url = "href='" + url + "'" |
|
} |
|
if (cls.length > 0) { |
|
cls = ' ' + cls |
|
} |
|
if (icon.length > 0) { |
|
return `<span class='btn${cls}'><a ${url} title='${text}'><i class='${icon}'></i>${text}</a></span>`; |
|
} else { |
|
return `<span class='btn${cls}'><a ${url} title='${text}'>${text}</a></span>`; |
|
} |
|
} |
|
|
|
hexo.extend.tag.register('btn', postBtn);
|
|
|