You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
thumbsup/src/website/theme-base/helpers/relative.js

14 lines
438 B
JavaScript

const path = require('node:path')
module.exports = (target, options) => {
// if already an absolute URL, do nothing
if (target.match(/^(http|https|file):\/\//)) {
return target
}
const albumPath = options.data.root.album.path
const relative = path.relative(path.dirname(albumPath), target)
const url = relative.replace(/\\/g, '/')
// Escape single/double quotes
return url.replace(/'/g, '%27').replace(/"/g, '%22')
}