From c5b86f7a201c638a60018c5df2b757a2ec07cdb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Wed, 12 May 2021 15:59:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0oss=5Flink=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tag/oss-link.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 scripts/tag/oss-link.js 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