From d40f354110e4d61e99ca1850b2073af4de3fe3ff Mon Sep 17 00:00:00 2001 From: Ricardo Date: Mon, 4 Jan 2021 10:53:16 +0000 Subject: [PATCH] fix: separate author names --- .../theme/components/blog/PostAuthor.vue | 29 ++++++++++++++----- src/.vuepress/theme/util/blogUtils.js | 6 +++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/.vuepress/theme/components/blog/PostAuthor.vue b/src/.vuepress/theme/components/blog/PostAuthor.vue index 98ab1057..ab023488 100644 --- a/src/.vuepress/theme/components/blog/PostAuthor.vue +++ b/src/.vuepress/theme/components/blog/PostAuthor.vue @@ -7,11 +7,17 @@ class="flex items-center" > {{ name }} + >{{ index === 0 ? '' : ',' }} + + {{ piece }} + + @@ -25,11 +31,20 @@ export default { mixins: [Author], computed: { ...mapState('appState', ['activeAuthor']), + resolvedAuthorName() { + const pieces = this.name.match(/[,&]/g) + + if (!pieces) { + return [this.name] + } + + return this.name.split(/[,&]/g) + }, }, methods: { - handleAuthorClick() { - if (!this.activeAuthor !== this.name) { - this.$store.commit('appState/setActiveAuthor', this.name) + handleAuthorClick(piece) { + if (!this.activeAuthor !== piece) { + this.$store.commit('appState/setActiveAuthor', piece) } }, }, diff --git a/src/.vuepress/theme/util/blogUtils.js b/src/.vuepress/theme/util/blogUtils.js index d4a8f34f..16e039aa 100644 --- a/src/.vuepress/theme/util/blogUtils.js +++ b/src/.vuepress/theme/util/blogUtils.js @@ -12,7 +12,11 @@ export const checkItem = ({ return false } - if (activeAuthor && decodeURI(activeAuthor) !== author.name) { + if ( + activeAuthor && + ((author.name && !author.name.includes(decodeURI(activeAuthor))) || + !author.name) + ) { return false }