aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services/ui/ldItemResourceUrl.ts
blob: d6734b3eea47ba599609f95d6578cea5ed000f5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { Item } from '@/@types/gallery';
import { useGalleryStore } from '@/store/galleryStore';
import { computed, ToRef } from 'vue';
import { isDownloadableItem } from '../itemGuards';

export const useItemResource = (item: ToRef<Item>) => {
  const galleryStore = useGalleryStore();
  const itemResourceUrl = computed(() => isDownloadableItem(item.value) ? galleryStore.resourceRoot + item.value.properties.resource : '');
  const thumbnailResourceUrl = computed(() => item.value.thumbnail ? galleryStore.resourceRoot + item.value.thumbnail.resource : '');

  return {
    itemResourceUrl,
    thumbnailResourceUrl,
  };
};