1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-24 13:26:08 +03:00
guide/front/client/page/CategoryPage.vue

49 lines
1012 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<category
:categoryId="categoryId"
/>
</template>
<script lang="ts">
import Vue from 'vue'
import Category from 'client/components/Category.vue'
import Component from 'vue-class-component'
import { Prop, Watch } from 'vue-property-decorator'
@Component({
components: {
Category
}
})
export default class CategoryPage extends Vue {
@Prop(String) categoryId!: string
get category () {
return this.$store.state.category.category
}
// TODO handle case when category was deleted. Go back in that case
async serverPrefetch () {
if (!this.categoryId) {
return
}
await this.$store.dispatch('category/loadCategory', this.categoryId)
}
beforeMount () {
this.$watch('category', this.setDocumentTitle, { immediate: true })
}
beforeDestroy () {
this.$store.commit('category/setCategory', null)
}
setDocumentTitle (category) {
document.title = category
? `${category.title} Aelve Guide`
: 'Aelve Guide'
}
}
</script>