'use strict' /* global hexo */ /* * Embed an image with responsive images in a post * https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images * Image is resized on-the-fly using Statically (https://statically.io/) * Usage: ![alt](/path/to/img "title") */ const { join } = require('path').posix hexo.extend.filter.register('marked:renderer', (renderer) => { renderer.image = (href, title, alt) => { if (!alt) alt = '' if (!title) title = alt if (href.endsWith('.svg')) return `${alt}` // embed external image if (!href.startsWith('20') && !href.startsWith('/20')) return `${alt}` const fLink = (path, width) => { const query = new URLSearchParams('f=auto') if (typeof width === 'number') query.set('width', width) const url = new URL('http://example.com/' + join('img', path) + '?' + query) return url.pathname + url.search } return `` + `${alt}` } })