@nuxt/image
Version:
Nuxt Image Module
19 lines (18 loc) • 491 B
JavaScript
import { joinURL } from "ufo";
import { createOperationsGenerator } from "../utils/index.js";
import { defineProvider } from "../utils/provider.js";
const operationsGenerator = createOperationsGenerator({
keyMap: {
width: "w",
height: "h",
quality: "q"
}
});
export default defineProvider({
getImage: (src, { modifiers }) => {
const operations = operationsGenerator(modifiers);
return {
url: joinURL(src + (operations ? "?" + operations : ""))
};
}
});