@@ -98,21 +101,7 @@ export default {
}
},
async fetch() {
- await this.$axios
- .get('/blog-posts/slug/' + this.$route.params.slug)
- .then(async (blogPost) => {
- this.blogPost = blogPost.data
-
- if (blogPost.data.parkId) {
- await this.loadPark(blogPost.data.parkId)
- await this.loadParkBlogPosts(blogPost.data.parkId)
- }
- })
- .catch((reason) => {
- this.$emit('fetchError', reason)
- this.$sentry.captureException(reason)
- throw reason
- })
+ await this.fetchBlogPost()
},
head() {
return {
@@ -146,14 +135,14 @@ export default {
},
]
- if (this.blogPost.parkId) {
+ if (this.blogPost.park_id) {
if (this.park) {
bc = bc.concat({ title: this.park.name, url: '/blog?park=' + this.park.id })
}
}
return bc.concat({
- title: this.blogPost.title,
+ title: this.blogPost.translations[0].title,
url: '#',
})
},
@@ -173,8 +162,8 @@ export default {
},
async loadParkBlogPosts(parkId) {
this.associatedBlogPosts = await this.$axios
- .get('/blog-posts/parks/' + parkId)
- .then(({ data: blogPosts }) => {
+ .get(`https://data.arendz.nl/items/tp_blogpost?filter[park_id][_eq]=${parkId}&fields=*,translations.*,header.*`)
+ .then(({ data: { data: blogPosts } }) => {
return blogPosts.filter((p) => p.id !== this.blogPost.id).slice(0, 5)
})
.catch((reason) => {
@@ -183,6 +172,31 @@ export default {
throw reason
})
},
+ async fetchBlogPost() {
+ await this.$axios
+ .get(
+ `https://data.arendz.nl/items/tp_blogpost?filter[translations][slug][_eq]=${this.$route.params.slug}&fields=*,translations.*,header.*,user_created.*`
+ )
+ .then(async (blogPosts) => {
+ const isoLocale = this.$i18n.locales.find((l) => l.code === this.$i18n.getLocaleCookie()).iso
+
+ if (blogPosts.data.data[0].translations[0].languages_code !== isoLocale) {
+ throw new Error('Not the right locale')
+ }
+
+ this.blogPost = blogPosts.data.data[0]
+
+ if (blogPosts.data.data[0].park_id) {
+ await this.loadPark(blogPosts.data.data[0].park_id)
+ await this.loadParkBlogPosts(blogPosts.data.data[0].park_id)
+ }
+ })
+ .catch((reason) => {
+ this.$emit('fetchError', reason)
+ this.$sentry.captureException(reason)
+ throw reason
+ })
+ },
},
}
diff --git a/pages/blog/create.vue b/pages/blog/create.vue
deleted file mode 100644
index ddbc82a..0000000
--- a/pages/blog/create.vue
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-
Nieuwe blogpost maken
-
-
-
-
-
-
{{ error }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/blog/index.vue b/pages/blog/index.vue
index 1b36060..70d1180 100644
--- a/pages/blog/index.vue
+++ b/pages/blog/index.vue
@@ -21,15 +21,16 @@