fix: separate author names

This commit is contained in:
Ricardo
2021-01-04 10:53:16 +00:00
parent 9f5245e195
commit d40f354110
2 changed files with 27 additions and 8 deletions

View File

@@ -7,11 +7,17 @@
class="flex items-center"
>
<span
v-for="(piece, index) in resolvedAuthorName"
:key="piece"
itemprop="name"
class="whitespace-no-wrap hover:text-blueGreen hover:underline cursor-pointer"
@click="handleAuthorClick()"
>{{ name }}</span
>
>{{ index === 0 ? '' : ',' }}
<span
class="whitespace-no-wrap hover:text-blueGreen hover:underline cursor-pointer"
@click="handleAuthorClick(piece)"
>
{{ piece }}
</span>
</span>
</div>
</template>
@@ -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)
}
},
},

View File

@@ -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
}