2022-08-27 10:44:58 -08:00
|
|
|
function UnknownToString(ukn: string | unknown) {
|
|
|
|
return typeof ukn === "string" ? ukn : "";
|
|
|
|
}
|
|
|
|
|
2021-08-09 16:19:23 -08:00
|
|
|
export const useStaticRoutes = () => {
|
2025-06-20 00:09:12 +07:00
|
|
|
const { $config } = useNuxtApp();
|
|
|
|
const serverBase = useRequestURL().origin;
|
2021-08-09 16:19:23 -08:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
const prefix = `${$config.public.SUB_PATH}/api`.replace("//", "/");
|
2021-08-09 16:19:23 -08:00
|
|
|
|
2021-12-06 17:14:14 -09:00
|
|
|
const fullBase = serverBase + prefix;
|
|
|
|
|
2021-08-09 16:19:23 -08:00
|
|
|
// Methods to Generate reference urls for assets/images *
|
2022-08-27 10:44:58 -08:00
|
|
|
function recipeImage(recipeId: string, version: string | unknown = "", key: string | number = 1) {
|
|
|
|
return `${fullBase}/media/recipes/${recipeId}/images/original.webp?rnd=${key}&version=${UnknownToString(version)}`;
|
2021-08-09 16:19:23 -08:00
|
|
|
}
|
|
|
|
|
2022-08-27 10:44:58 -08:00
|
|
|
function recipeSmallImage(recipeId: string, version: string | unknown = "", key: string | number = 1) {
|
|
|
|
return `${fullBase}/media/recipes/${recipeId}/images/min-original.webp?rnd=${key}&version=${UnknownToString(
|
2025-06-20 00:09:12 +07:00
|
|
|
version,
|
2022-08-27 10:44:58 -08:00
|
|
|
)}`;
|
2021-08-09 16:19:23 -08:00
|
|
|
}
|
|
|
|
|
2022-08-27 10:44:58 -08:00
|
|
|
function recipeTinyImage(recipeId: string, version: string | unknown = "", key: string | number = 1) {
|
|
|
|
return `${fullBase}/media/recipes/${recipeId}/images/tiny-original.webp?rnd=${key}&version=${UnknownToString(
|
2025-06-20 00:09:12 +07:00
|
|
|
version,
|
2022-08-27 10:44:58 -08:00
|
|
|
)}`;
|
2021-08-09 16:19:23 -08:00
|
|
|
}
|
|
|
|
|
2023-08-06 12:49:30 -05:00
|
|
|
function recipeTimelineEventImage(recipeId: string, timelineEventId: string) {
|
|
|
|
return `${fullBase}/media/recipes/${recipeId}/images/timeline/${timelineEventId}/original.webp`;
|
|
|
|
}
|
|
|
|
|
|
|
|
function recipeTimelineEventSmallImage(recipeId: string, timelineEventId: string) {
|
|
|
|
return `${fullBase}/media/recipes/${recipeId}/images/timeline/${timelineEventId}/min-original.webp`;
|
|
|
|
}
|
|
|
|
|
|
|
|
function recipeTimelineEventTinyImage(recipeId: string, timelineEventId: string) {
|
|
|
|
return `${fullBase}/media/recipes/${recipeId}/images/timeline/${timelineEventId}/tiny-original.webp`;
|
|
|
|
}
|
|
|
|
|
2022-02-13 12:23:42 -09:00
|
|
|
function recipeAssetPath(recipeId: string, assetName: string) {
|
|
|
|
return `${fullBase}/media/recipes/${recipeId}/assets/${assetName}`;
|
2021-08-09 16:19:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
recipeImage,
|
|
|
|
recipeSmallImage,
|
|
|
|
recipeTinyImage,
|
2023-08-06 12:49:30 -05:00
|
|
|
recipeTimelineEventImage,
|
|
|
|
recipeTimelineEventSmallImage,
|
|
|
|
recipeTimelineEventTinyImage,
|
2021-08-09 16:19:23 -08:00
|
|
|
recipeAssetPath,
|
|
|
|
};
|
|
|
|
};
|