2021-08-21 23:23:35 +02:00
|
|
|
<template>
|
2022-01-04 14:36:52 +01:00
|
|
|
<div class="flex items-center h-full px-1 overflow-hidden">
|
2022-03-13 18:39:12 +01:00
|
|
|
<covers-book-cover :library-item="libraryItem" :width="coverWidth" :book-cover-aspect-ratio="bookCoverAspectRatio" />
|
2021-10-17 18:29:52 +02:00
|
|
|
<div class="flex-grow px-2 audiobookSearchCardContent">
|
|
|
|
<p v-if="matchKey !== 'title'" class="truncate text-sm">{{ title }}</p>
|
|
|
|
<p v-else class="truncate text-sm" v-html="matchHtml" />
|
|
|
|
|
|
|
|
<p v-if="matchKey === 'subtitle'" class="truncate text-xs text-gray-300">{{ matchHtml }}</p>
|
|
|
|
|
2022-03-13 18:39:12 +01:00
|
|
|
<p v-if="matchKey !== 'authors'" class="text-xs text-gray-200 truncate">by {{ authorName }}</p>
|
2021-10-17 18:29:52 +02:00
|
|
|
<p v-else class="truncate text-xs text-gray-200" v-html="matchHtml" />
|
|
|
|
|
2022-01-10 01:37:16 +01:00
|
|
|
<div v-if="matchKey === 'series' || matchKey === 'tags' || matchKey === 'isbn' || matchKey === 'asin'" class="m-0 p-0 truncate text-xs" v-html="matchHtml" />
|
2021-08-21 23:23:35 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
2022-03-13 18:39:12 +01:00
|
|
|
libraryItem: {
|
2021-08-21 23:23:35 +02:00
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
2021-10-17 18:29:52 +02:00
|
|
|
},
|
|
|
|
search: String,
|
|
|
|
matchKey: String,
|
|
|
|
matchText: String
|
2021-08-21 23:23:35 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
computed: {
|
2021-12-03 02:02:38 +01:00
|
|
|
bookCoverAspectRatio() {
|
|
|
|
return this.$store.getters['getBookCoverAspectRatio']
|
|
|
|
},
|
|
|
|
coverWidth() {
|
|
|
|
if (this.bookCoverAspectRatio === 1) return 50 * 1.2
|
|
|
|
return 50
|
|
|
|
},
|
2022-03-13 18:39:12 +01:00
|
|
|
media() {
|
|
|
|
return this.libraryItem ? this.libraryItem.media || {} : {}
|
|
|
|
},
|
2022-04-12 23:54:52 +02:00
|
|
|
mediaType() {
|
|
|
|
return this.libraryItem ? this.libraryItem.mediaType : null
|
|
|
|
},
|
|
|
|
isPodcast() {
|
|
|
|
return this.mediaType == 'podcast'
|
|
|
|
},
|
2022-03-13 18:39:12 +01:00
|
|
|
mediaMetadata() {
|
|
|
|
return this.media.metadata || {}
|
2021-08-21 23:23:35 +02:00
|
|
|
},
|
|
|
|
title() {
|
2022-03-13 18:39:12 +01:00
|
|
|
return this.mediaMetadata.title || 'No Title'
|
2021-08-21 23:23:35 +02:00
|
|
|
},
|
2021-10-17 18:29:52 +02:00
|
|
|
subtitle() {
|
2022-03-13 18:39:12 +01:00
|
|
|
return this.mediaMetadata.subtitle || ''
|
|
|
|
},
|
|
|
|
authorName() {
|
2022-04-12 23:54:52 +02:00
|
|
|
if (this.isPodcast) return this.mediaMetadata.author || 'Unknown'
|
|
|
|
return this.mediaMetadata.authorName || 'Unknown'
|
2021-10-17 18:29:52 +02:00
|
|
|
},
|
|
|
|
matchHtml() {
|
|
|
|
if (!this.matchText || !this.search) return ''
|
|
|
|
if (this.matchKey === 'subtitle') return ''
|
|
|
|
|
2022-06-26 22:46:16 +02:00
|
|
|
// This used to highlight the part of the search found
|
|
|
|
// but with removing commas periods etc this is no longer plausible
|
|
|
|
const html = this.matchText
|
2021-10-17 18:29:52 +02:00
|
|
|
|
|
|
|
if (this.matchKey === 'tags') return `<p class="truncate">Tags: ${html}</p>`
|
2022-03-13 18:39:12 +01:00
|
|
|
if (this.matchKey === 'authors') return `by ${html}`
|
2022-01-04 14:36:52 +01:00
|
|
|
if (this.matchKey === 'isbn') return `<p class="truncate">ISBN: ${html}</p>`
|
2022-01-10 01:37:16 +01:00
|
|
|
if (this.matchKey === 'asin') return `<p class="truncate">ASIN: ${html}</p>`
|
2021-10-17 19:18:26 +02:00
|
|
|
if (this.matchKey === 'series') return `<p class="truncate">Series: ${html}</p>`
|
2021-10-17 18:29:52 +02:00
|
|
|
return `${html}`
|
2021-08-21 23:23:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2021-10-17 18:29:52 +02:00
|
|
|
.audiobookSearchCardContent {
|
2021-08-21 23:23:35 +02:00
|
|
|
width: calc(100% - 80px);
|
2021-10-17 18:29:52 +02:00
|
|
|
height: 75px;
|
2021-08-21 23:23:35 +02:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
</style>
|