'use strict' /* global hexo */ /* * Put {% image 'folder/filename.jpg' 'description' %} in your post. */ hexo.extend.tag.register('image', (args) => { let [fileName, alt] = args if (!alt) alt = '' let modern = fileName let legacy = fileName const link = '/img/' if (fileName.endsWith('.png') || fileName.endsWith('.jpg')) { modern = fileName.concat('?format=webp') } else if (fileName.endsWith('.webp')) { // Statically has yet to support animated webp // https://github.com/marsble/statically/issues/36 // modern = fileName.concat('?auto_format=false') modern = fileName.replace(/\.webp$/, '.gif') legacy = fileName.replace(/\.webp$/, '.gif') } const modernLink = link + modern const legacyLink = link + legacy const img = `${alt}` if (fileName.endsWith('.png') || fileName.endsWith('.webp')) { return ` ${img} ` } else { return `${img}` } })