'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 ``
// embed external image
if (href.startsWith('http')) return ``
const fLink = (path, width = '') => {
const url = new URL(join('images', width, path), 'http://example.com/')
return url.pathname
}
return `` +
``
}
})