2021-08-09 04:52:44 +00:00
|
|
|
<template>
|
|
|
|
<v-container>
|
|
|
|
<RecipeCardSection
|
2021-09-05 04:24:32 +00:00
|
|
|
v-if="category"
|
2021-08-09 04:52:44 +00:00
|
|
|
:icon="$globals.icons.tags"
|
|
|
|
:title="category.name"
|
|
|
|
:recipes="category.recipes"
|
|
|
|
@sort="assignSorted"
|
|
|
|
></RecipeCardSection>
|
|
|
|
</v-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent, useAsync, useRoute } from "@nuxtjs/composition-api";
|
|
|
|
import RecipeCardSection from "~/components/Domain/Recipe/RecipeCardSection.vue";
|
|
|
|
import { useApiSingleton } from "~/composables/use-api";
|
|
|
|
import { Recipe } from "~/types/api-types/recipe";
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: { RecipeCardSection },
|
|
|
|
setup() {
|
|
|
|
const api = useApiSingleton();
|
|
|
|
const route = useRoute();
|
|
|
|
const slug = route.value.params.slug;
|
|
|
|
|
|
|
|
const category = useAsync(async () => {
|
|
|
|
const { data } = await api.categories.getOne(slug);
|
|
|
|
return data;
|
|
|
|
}, slug);
|
|
|
|
return { category };
|
|
|
|
},
|
2021-10-07 17:39:47 +00:00
|
|
|
head() {
|
|
|
|
return {
|
|
|
|
title: this.$t("sidebar.categories") as string,
|
|
|
|
};
|
|
|
|
},
|
2021-08-09 04:52:44 +00:00
|
|
|
methods: {
|
|
|
|
assignSorted(val: Array<Recipe>) {
|
2021-08-09 05:15:20 +00:00
|
|
|
if (this.category) {
|
2021-10-07 19:13:05 +00:00
|
|
|
// @ts-ignore
|
2021-08-09 05:15:20 +00:00
|
|
|
this.category.recipes = val;
|
|
|
|
}
|
2021-08-09 04:52:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
</style>
|