fix: useStorage in ssr & extract random
This commit is contained in:
19
composables/recipe.ts
Normal file
19
composables/recipe.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import recipeData from '~/data/recipe.json'
|
||||
import type { RecipeItem, Recipes } from '~/types'
|
||||
|
||||
export function useRandomRecipe() {
|
||||
const randomRecipe = ref<RecipeItem>()
|
||||
function random() {
|
||||
randomRecipe.value = generateRandomRecipe(recipeData as Recipes)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
random()
|
||||
})
|
||||
|
||||
return {
|
||||
random,
|
||||
|
||||
randomRecipe,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user