feat:增加oss_link连接功能。
This commit is contained in:
parent
adb0e6c7f3
commit
c5b86f7a20
26
scripts/tag/oss-link.js
Normal file
26
scripts/tag/oss-link.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
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>`
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user