Skip to content

Commit

Permalink
fix: 3D NFT Thumbnail Preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarsen136 committed Aug 25, 2023
1 parent 9b85a3c commit ee3f53c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 60 deletions.
8 changes: 8 additions & 0 deletions components/base/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ export interface CarouselNFT extends ItemResources {
collectionName?: string
chain?: Prefix
}

export interface BaseNFTMeta {
id: string
image?: string
animationUrl?: string
name?: string
description?: string
}
3 changes: 2 additions & 1 deletion components/carousel/CarouselTypeRelated.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<template>
<CarouselIndex :title="`${$t('nft.related')}`" :nfts="nfts" />
<CarouselIndex :title="`${$t('nft.related')}`" :nfts="formatNFT(nfts)" />
</template>

<script lang="ts" setup>
import { useCarouselRelated } from './utils/useCarousel'
import { formatNFT } from '@/utils/carousel'
const props = defineProps<{
collectionId: string
Expand Down
27 changes: 0 additions & 27 deletions components/shared/gallery/GalleryItemCardList.vue

This file was deleted.

28 changes: 0 additions & 28 deletions components/shared/gallery/NftCard.vue

This file was deleted.

9 changes: 5 additions & 4 deletions composables/useNft.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { NFT, NFTMetadata } from '@/components/rmrk/service/scheme'
import { sanitizeIpfsUrl } from '@/utils/ipfs'
import type { BaseNFTMeta } from '@/components/base/types'
import { processSingleMetadata } from '@/utils/cachingStrategy'
import { getMimeType } from '@/utils/gallery/media'
import unionBy from 'lodash/unionBy'
Expand All @@ -22,15 +23,15 @@ export type ItemResources = {
}

export type NFTWithMetadata = NFT &
NFTMetadata & { meta: NFTMetadata } & ItemResources
NFTMetadata & { meta: BaseNFTMeta } & ItemResources

function getGeneralMetadata(nft: NFTWithMetadata) {
return {
...nft,
name: nft.name || nft.meta.name || nft.id,
description: nft.description || nft.meta.description || '',
image: sanitizeIpfsUrl(nft.meta.image),
animation_url: sanitizeIpfsUrl(nft.meta.animation_url || ''),
animationUrl: sanitizeIpfsUrl(nft.meta.animation_url || ''),
type: nft.meta.type || '',
}
}
Expand All @@ -53,7 +54,7 @@ async function getProcessMetadata(nft: NFTWithMetadata) {
nft.metadata
)) as NFTWithMetadata
const image = sanitizeIpfsUrl(metadata.image || metadata.mediaUri || '')
const animation_url = sanitizeIpfsUrl(metadata.animation_url || '')
const animationUrl = sanitizeIpfsUrl(metadata.animation_url || '')
const getAttributes = () => {
const hasMetadataAttributes =
metadata.attributes && metadata.attributes.length > 0
Expand All @@ -73,7 +74,7 @@ async function getProcessMetadata(nft: NFTWithMetadata) {
name: nft.name || metadata.name || nft.id,
description: nft.description || metadata.description || '',
image,
animation_url,
animationUrl,
type: metadata.type || '',
attributes: getAttributes(),
}
Expand Down

0 comments on commit ee3f53c

Please sign in to comment.