feat: add emojis for recipe
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useGtm } from '@gtm-support/vue-gtm'
|
import { useGtm } from '@gtm-support/vue-gtm'
|
||||||
|
import { meat, staple, vegetable } from '~/data/food'
|
||||||
import type { RecipeItem } from '~/types'
|
import type { RecipeItem } from '~/types'
|
||||||
defineProps<{
|
defineProps<{
|
||||||
dish: RecipeItem
|
dish: RecipeItem
|
||||||
@@ -15,6 +16,21 @@ const triggerGtm = (val: string) => {
|
|||||||
label: '跳转菜谱',
|
label: '跳转菜谱',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getDishName = (dish: RecipeItem) => {
|
||||||
|
const name = dish.name
|
||||||
|
const emojis: string[] = []
|
||||||
|
dish.stuff.forEach((item) => {
|
||||||
|
const kinds = [vegetable, meat, staple]
|
||||||
|
kinds.forEach((kind) => {
|
||||||
|
kind.forEach((m) => {
|
||||||
|
if (m.name === item)
|
||||||
|
emojis.push(m.emoji)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return `${emojis.join(' ')} ${name}`
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -24,6 +40,6 @@ const triggerGtm = (val: string) => {
|
|||||||
bg="blue-300 opacity-20"
|
bg="blue-300 opacity-20"
|
||||||
@click="triggerGtm(dish.name)"
|
@click="triggerGtm(dish.name)"
|
||||||
>
|
>
|
||||||
<span text="sm blue-700 dark:blue-200">{{ dish.name }}</span>
|
<span text="sm blue-700 dark:blue-200">{{ getDishName(dish) }}</span>
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user