diff --git a/components/BlogEntriesList.vue b/components/BlogEntriesList.vue index afdef110..bac9f189 100644 --- a/components/BlogEntriesList.vue +++ b/components/BlogEntriesList.vue @@ -40,9 +40,11 @@ }, data() { const shortcuts = {}; - for (let shortcut in this.config.blog.shortcuts) { - if (!this.config.blog.shortcuts.hasOwnProperty(shortcut)) { continue; } - shortcuts[this.config.blog.shortcuts[shortcut]] = shortcut; + if (this.config.blog && this.config.blog.shortcuts) { + for (let shortcut in this.config.blog.shortcuts) { + if (!this.config.blog.shortcuts.hasOwnProperty(shortcut)) { continue; } + shortcuts[this.config.blog.shortcuts[shortcut]] = shortcut; + } } return { shortcuts }; diff --git a/routes/homepage.vue b/routes/homepage.vue index e07bf084..dc0673b5 100644 --- a/routes/homepage.vue +++ b/routes/homepage.vue @@ -113,7 +113,9 @@ }; }, async mounted() { - this.posts = await this.$axios.$get(`/blog?shortcuts`); + if (this.config.blog && this.config.blog.shortcuts) { + this.posts = await this.$axios.$get(`/blog?shortcuts`); + } }, } diff --git a/server/routes/blog.js b/server/routes/blog.js index 996dbe18..5e43e290 100644 --- a/server/routes/blog.js +++ b/server/routes/blog.js @@ -66,10 +66,12 @@ router.get('/blog', handleErrorAsync(async (req, res) => { return posts; }) - if (req.query.shortcuts !== undefined && global.config.blog && global.config.blog.shortcuts) { + if (req.query.shortcuts !== undefined) { const postsShortcuts = []; - for (let slug of Object.values(global.config.blog.shortcuts)) { - postsShortcuts.push(posts.filter(p => p.slug === slug)[0]) + if (global.config.blog && global.config.blog.shortcuts) { + for (let slug of Object.values(global.config.blog.shortcuts)) { + postsShortcuts.push(posts.filter(p => p.slug === slug)[0]) + } } return res.json(postsShortcuts);