[blog][bug] locales without shortcuts would show all entries instead of none
This commit is contained in:
parent
f1ecd9878b
commit
1f91f09a48
|
@ -40,10 +40,12 @@
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const shortcuts = {};
|
const shortcuts = {};
|
||||||
|
if (this.config.blog && this.config.blog.shortcuts) {
|
||||||
for (let shortcut in this.config.blog.shortcuts) {
|
for (let shortcut in this.config.blog.shortcuts) {
|
||||||
if (!this.config.blog.shortcuts.hasOwnProperty(shortcut)) { continue; }
|
if (!this.config.blog.shortcuts.hasOwnProperty(shortcut)) { continue; }
|
||||||
shortcuts[this.config.blog.shortcuts[shortcut]] = shortcut;
|
shortcuts[this.config.blog.shortcuts[shortcut]] = shortcut;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { shortcuts };
|
return { shortcuts };
|
||||||
},
|
},
|
||||||
|
|
|
@ -113,7 +113,9 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
if (this.config.blog && this.config.blog.shortcuts) {
|
||||||
this.posts = await this.$axios.$get(`/blog?shortcuts`);
|
this.posts = await this.$axios.$get(`/blog?shortcuts`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -66,11 +66,13 @@ router.get('/blog', handleErrorAsync(async (req, res) => {
|
||||||
return posts;
|
return posts;
|
||||||
})
|
})
|
||||||
|
|
||||||
if (req.query.shortcuts !== undefined && global.config.blog && global.config.blog.shortcuts) {
|
if (req.query.shortcuts !== undefined) {
|
||||||
const postsShortcuts = [];
|
const postsShortcuts = [];
|
||||||
|
if (global.config.blog && global.config.blog.shortcuts) {
|
||||||
for (let slug of Object.values(global.config.blog.shortcuts)) {
|
for (let slug of Object.values(global.config.blog.shortcuts)) {
|
||||||
postsShortcuts.push(posts.filter(p => p.slug === slug)[0])
|
postsShortcuts.push(posts.filter(p => p.slug === slug)[0])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return res.json(postsShortcuts);
|
return res.json(postsShortcuts);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue