[blog][bug] locales without shortcuts would show all entries instead of none
This commit is contained in:
parent
f1ecd9878b
commit
1f91f09a48
|
@ -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 };
|
||||
|
|
|
@ -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`);
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -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);
|
||||
|
|
Reference in New Issue