Open external links in new tab for buy and discogs buttons

This commit is contained in:
Michael Winter 2026-02-19 03:12:03 +01:00
parent 9d7ecd3dd1
commit af0dc19861

View file

@ -6,21 +6,21 @@
<Icon name="ion:book-sharp" style="color: white" />
</button>
<button v-else-if="type === 'document'" @click="modalStore.setModalProps('pdf', 'aspect-[1/1.414]', true, '', '', '', link)" class="inline-flex p-1">
<a v-else-if="type === 'document'" :href="isExternalLink ? link : undefined" :target="isExternalLink ? '_blank' : undefined" :rel="isExternalLink ? 'noopener noreferrer' : undefined" @click="!isExternalLink && openDocument()" class="inline-flex p-1">
<Icon name="ion:book-sharp" style="color: white" />
</button>
</a>
<NuxtLink v-else-if="type === 'buy'" class="inline-flex p-1" :to="link">
<a v-else-if="type === 'buy'" :href="link" :target="newTab ? '_blank' : undefined" :rel="newTab ? 'noopener noreferrer' : undefined" class="inline-flex p-1">
<Icon name="bxs:purchase-tag" style="color: white" />
</NuxtLink>
</a>
<NuxtLink v-else-if="type === 'email'" class="inline-flex p-1" :to="link">
<Icon name="ic:baseline-email" style="color: white" />
</NuxtLink>
<NuxtLink v-else-if="type === 'discogs'" class="inline-flex p-1" :to="link">
<a v-else-if="type === 'discogs'" :href="link" :target="newTab ? '_blank' : undefined" :rel="newTab ? 'noopener noreferrer' : undefined" class="inline-flex p-1">
<Icon name="simple-icons:discogs" style="color: white" />
</NuxtLink>
</a>
<button @click="audioPlayerStore.setSoundCloudTrackID(work.soundcloud_trackid)" v-else-if="type === 'audio'" class="inline-flex p-1">
<Icon name="wpf:speaker" style="color: white" />
@ -41,14 +41,20 @@
<script setup>
import { useAudioPlayerStore } from "@/stores/AudioPlayerStore"
import { useModalStore } from "@/stores/ModalStore"
import { computed } from "vue"
const props = defineProps(['type', 'work', 'visible', 'link', 'newTab'])
const audioPlayerStore = useAudioPlayerStore()
const modalStore = useModalStore()
</script>
const isExternalLink = computed(() => {
return props.link && !props.link.endsWith('.pdf')
})
<script>
export default {
props: ['type', 'work', 'visible', 'link', 'newTab']
const openDocument = () => {
if (props.link?.endsWith('.pdf')) {
modalStore.setModalProps('pdf', 'aspect-[1/1.414]', true, '', '', '', props.link)
}
}
</script>