From f39bab62deece02b715d2e945609abcebfdbe49f Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Fri, 30 Aug 2019 05:52:16 +0100 Subject: [PATCH] refactor(cloudinary): combine variables --- scripts/cloudinary.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/scripts/cloudinary.js b/scripts/cloudinary.js index aa291b1..5728945 100644 --- a/scripts/cloudinary.js +++ b/scripts/cloudinary.js @@ -10,7 +10,7 @@ hexo.extend.tag.register('cloudinary', (args) => { const user = 'curben' - let fileName = args[0] + const fileName = args[0] const alt = args[1] || '' let modern = '' let legacy = '' @@ -26,37 +26,36 @@ hexo.extend.tag.register('cloudinary', (args) => { legacy = fileName } - fileName += '?auto_format=false' - modern += '?auto_format=false' - legacy += '?auto_format=false' + const modernLink = link + '/' + modern + '?auto_format=false' + const legacyLink = link + '/' + legacy + '?auto_format=false' const img = `${alt}` if (fileName.endsWith('.png') || fileName.endsWith('.webp')) { - return ` - ` + ` } else { - return `` + return `${img}` } })