@nuxt/image
Version:
Nuxt Image Module
18 lines (17 loc) • 474 B
JavaScript
import { joinURL } from "ufo";
import { createOperationsGenerator } from "#image";
export const operationsGenerator = createOperationsGenerator({
keyMap: {
width: "w",
height: "h",
quality: "q"
},
joinWith: "&",
formatter: (key, value) => `${key}=${value}`
});
export const getImage = (src, { modifiers = {} } = {}) => {
const operations = operationsGenerator(modifiers);
return {
url: joinURL(src + (operations ? "?" + operations : ""))
};
};