26 lines
741 B
JavaScript
26 lines
741 B
JavaScript
hexo.extend.tag.register('oss_link', function(args) {
|
|
const { config } = hexo;
|
|
|
|
const src = args.shift() || '';
|
|
// let versionId = args[1] || '';
|
|
if (src.length === 0) {
|
|
return '';
|
|
}
|
|
const fullUrl = `${config.oss.endpoint}/${src}`;
|
|
const description = args.shift() || src;
|
|
const title = args.shift() || description;
|
|
const blank = args.shift() === "true" || false;
|
|
const classes = args.shift() || '';
|
|
|
|
let attrs = [];
|
|
attrs.push(`href="${fullUrl}"`);
|
|
attrs.push(`title="${title}"`)
|
|
if (blank) {
|
|
attrs.push(`target="_blank"`);
|
|
}
|
|
if (classes.length !== 0) {
|
|
attrs.push(`class="${classes}"`);
|
|
}
|
|
|
|
return `<a ${attrs.join(' ')}>${description}</a>`
|
|
}); |