Initial export from WebStudio.is

This commit is contained in:
deterge
2025-10-08 18:18:41 -04:00
parent bb56cf1878
commit 903e016eec
54 changed files with 90905 additions and 0 deletions

35
app/constants.mjs Normal file
View File

@@ -0,0 +1,35 @@
/**
* We use mjs extension as constants in this file is shared with the build script
* and we use `node --eval` to extract the constants.
*/
export const assetBaseUrl = "/assets/";
/**
* URL.canParse(props.src)
* @type {(url: string) => boolean}
*/
const UrlCanParse = (url) => {
try {
new URL(url);
return true;
} catch {
return false;
}
};
/**
* @type {import("@webstudio-is/image").ImageLoader}
*/
export const imageLoader = (props) => {
if (props.format === "raw") {
return props.src;
}
// IPX (sharp) does not support ico
if (props.src.endsWith('.ico')) {
return props.src;
}
// handle absolute urls
const path = UrlCanParse(props.src) ? `/${props.src}` : props.src;
// https://github.com/unjs/ipx?tab=readme-ov-file#modifiers
return `/_image/w_${props.width},q_${props.quality}${path}`;
};