Use Prettier

This commit is contained in:
prototypa
2022-09-11 03:51:55 -04:00
parent 51362812c8
commit d909adb658
52 changed files with 1487 additions and 1447 deletions

View File

@@ -1,37 +1,37 @@
const load = async function () {
let images = [];
try {
images = import.meta.glob("~/assets/images/**");
} catch (e) {
// continue regardless of error
}
return images;
let images = [];
try {
images = import.meta.glob('~/assets/images/**');
} catch (e) {
// continue regardless of error
}
return images;
};
let _images;
/** */
export const fetchLocalImages = async () => {
_images = _images || load();
return await _images;
_images = _images || load();
return await _images;
};
/** */
export const findImage = async (imagePath) => {
if (typeof imagePath !== "string") {
return null;
}
if (typeof imagePath !== 'string') {
return null;
}
if (imagePath.startsWith("http://") || imagePath.startsWith("https://")) {
return imagePath;
}
if (imagePath.startsWith('http://') || imagePath.startsWith('https://')) {
return imagePath;
}
if (!imagePath.startsWith("~/assets")) {
return null;
} // For now only consume images using ~/assets alias (or absolute)
if (!imagePath.startsWith('~/assets')) {
return null;
} // For now only consume images using ~/assets alias (or absolute)
const images = await fetchLocalImages();
const key = imagePath.replace("~/", "/src/");
const images = await fetchLocalImages();
const key = imagePath.replace('~/', '/src/');
return typeof images[key] === "function" ? (await images[key]())["default"] : null;
return typeof images[key] === 'function' ? (await images[key]())['default'] : null;
};