[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() {
|
data() {
|
||||||
const shortcuts = {};
|
const shortcuts = {};
|
||||||
for (let shortcut in this.config.blog.shortcuts) {
|
if (this.config.blog && this.config.blog.shortcuts) {
|
||||||
if (!this.config.blog.shortcuts.hasOwnProperty(shortcut)) { continue; }
|
for (let shortcut in this.config.blog.shortcuts) {
|
||||||
shortcuts[this.config.blog.shortcuts[shortcut]] = shortcut;
|
if (!this.config.blog.shortcuts.hasOwnProperty(shortcut)) { continue; }
|
||||||
|
shortcuts[this.config.blog.shortcuts[shortcut]] = shortcut;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { shortcuts };
|
return { shortcuts };
|
||||||
|
|
|
@ -113,7 +113,9 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async mounted() {
|
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>
|
</script>
|
||||||
|
|
|
@ -66,10 +66,12 @@ 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 = [];
|
||||||
for (let slug of Object.values(global.config.blog.shortcuts)) {
|
if (global.config.blog && global.config.blog.shortcuts) {
|
||||||
postsShortcuts.push(posts.filter(p => p.slug === slug)[0])
|
for (let slug of Object.values(global.config.blog.shortcuts)) {
|
||||||
|
postsShortcuts.push(posts.filter(p => p.slug === slug)[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.json(postsShortcuts);
|
return res.json(postsShortcuts);
|
||||||
|
|
Reference in New Issue