[blog][bug] locales without shortcuts would show all entries instead of none

This commit is contained in:
Andrea 2022-01-21 10:51:51 +01:00
parent f1ecd9878b
commit 1f91f09a48
3 changed files with 13 additions and 7 deletions

View File

@ -40,10 +40,12 @@
},
data() {
const shortcuts = {};
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 };
},

View File

@ -113,7 +113,9 @@
};
},
async mounted() {
if (this.config.blog && this.config.blog.shortcuts) {
this.posts = await this.$axios.$get(`/blog?shortcuts`);
}
},
}
</script>

View File

@ -66,11 +66,13 @@ 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 = [];
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);
}