Lyliya
Lyliya
NNuxt
Created by Lyliya on 2/7/2025 in #❓・help
NuxtImage: Relative import
Currently I am using a custom provider like this, but it feel weird, I wonder if there is a better solution
export const getImage: ProviderGetImage = (
src,
{ modifiers = {}, baseURL } = {}
) => {
if (!baseURL) {
// also support runtime config
baseURL = useRuntimeConfig().public.siteUrl;
}

const operations = operationsGenerator(modifiers);

return {
url: joinURL("./", baseURL, src + (operations ? "?" + operations : "")),
};
};
export const getImage: ProviderGetImage = (
src,
{ modifiers = {}, baseURL } = {}
) => {
if (!baseURL) {
// also support runtime config
baseURL = useRuntimeConfig().public.siteUrl;
}

const operations = operationsGenerator(modifiers);

return {
url: joinURL("./", baseURL, src + (operations ? "?" + operations : "")),
};
};
7 replies
NNuxt
Created by Lyliya on 2/7/2025 in #❓・help
NuxtImage: Relative import
You did great AI, but I already tried and this does not work 😭
7 replies