mirror of
https://github.com/runyanjake/cooking.git
synced 2026-09-25 12:48:40 -07:00
18 lines
612 B
TypeScript
18 lines
612 B
TypeScript
// Client-safe URL helpers (no fs imports)
|
|
|
|
interface RecipeLocation {
|
|
category: string;
|
|
slug: string;
|
|
}
|
|
|
|
// Rewrites a recipe-relative path like "./assets/hero.jpg" to its served URL
|
|
export function resolveRecipeAssetUrl(recipe: RecipeLocation, src: string): string {
|
|
if (!src.startsWith('./')) return src;
|
|
return `/recipes/${recipe.category}/${recipe.slug}/${src.slice(2)}`;
|
|
}
|
|
|
|
// Generated recipe card image, e.g. "card.png" or "front.png"
|
|
export function recipeCardImageUrl(recipe: RecipeLocation, fileName: string): string {
|
|
return `/recipes/${recipe.category}/${recipe.slug}/card/${fileName}`;
|
|
}
|