diff --git a/scripts/tag/oss-link.js b/scripts/tag/oss-link.js new file mode 100644 index 0000000..3ad9d42 --- /dev/null +++ b/scripts/tag/oss-link.js @@ -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 `${description}` +}); \ No newline at end of file