'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")
*/
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('20')) return ``
// Statically doesn't support WebP and GIF
if (href.endsWith('.webp')) {
const gif = href.replace(/\.webp$/, '.gif')
return ``
}
const fLink = (str, width) => {
if (typeof width === 'number') width = ',w=' + width.toString()
else width = ''
return '/img/gitlab.com/f=auto' + width + '/curben/blog/-/raw/site/' + str
}
return `` +
``
}
})