gancio/pages/announcement/_id.vue

38 lines
903 B
Vue
Raw Normal View History

<template lang="pug">
2022-07-01 15:55:09 +02:00
v-container
v-card
v-card-title {{announcement.title}}
v-card-text(v-html='announcement.announcement')
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'Announcement',
2022-07-01 15:55:09 +02:00
asyncData ({ params, error, store }) {
try {
const id = Number(params.id)
const announcement = store.state.announcements.find(a => a.id === id)
2021-05-31 00:08:13 +02:00
if (!announcement) {
error({ statusCode: 404, message: 'Announcement not found' })
}
return { announcement }
} catch (e) {
error({ statusCode: 404, message: 'Announcement not found' })
}
},
2021-03-05 14:20:32 +01:00
data () {
return { announcement: { title: '' } }
},
2021-05-31 00:08:13 +02:00
head () {
if (!this.announcement) {
return {}
}
2021-05-31 00:08:13 +02:00
return {
title: `${this.settings.title} - ${this.announcement.title}`
}
},
computed: mapState(['announcements', 'settings'])
}
</script>