Skip to content

Commit

Permalink
Merge pull request #11117 from hassnian/issue-collection-banner
Browse files Browse the repository at this point in the history
feat: collection banner use `banner` field
  • Loading branch information
vikiival authored Oct 19, 2024
2 parents e6751b1 + e82292a commit ad9f811
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
17 changes: 11 additions & 6 deletions components/collection/CollectionHeader/CollectionBanner.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div
class="collection-banner relative md:h-[560px] h-72 bg-no-repeat bg-cover bg-center border-b"
:style="{ backgroundImage: `url(${bannerImageUrl})` }"
:style="{ backgroundImage: `url(${collectionBanner})` }"
>
<div class="collection-banner-shadow absolute inset-0" />

Expand Down Expand Up @@ -55,38 +55,43 @@ const props = defineProps<{
const route = useRoute()
const collectionAvatar = ref('')
const collectionBanner = ref('')
const collectionName = ref('--')
const bannerImageUrl = computed(
() => collectionAvatar.value && toOriginalContentUrl(collectionAvatar.value),
)
watch(() => props.collectionId, () => {
collectionAvatar.value = ''
collectionBanner.value = ''
collectionName.value = '--'
})
watchEffect(async () => {
const collection = props.collection
const metadata = collection?.metadata
const image = collection?.meta?.image
const banner = collection?.meta?.banner || image
const name = collection?.name
if (image && name) {
if (image && name && banner) {
collectionAvatar.value = sanitizeIpfsUrl(image)
collectionBanner.value = toOriginalContentUrl(sanitizeIpfsUrl(banner))
collectionName.value = name
}
else {
const meta = (await processSingleMetadata(
metadata as string,
)) as NFTMetadata
const metaImage = sanitizeIpfsUrl(meta?.image)
const metaBanner = meta?.banner ? sanitizeIpfsUrl(meta?.banner) : metaImage
const metaName = meta?.name
if (metaName) {
collectionName.value = metaName
}
if (metaBanner) {
collectionBanner.value = toOriginalContentUrl(metaBanner)
}
if (metaImage) {
collectionAvatar.value = metaImage
}
Expand Down
1 change: 1 addition & 0 deletions queries/subsquid/general/collectionByIdMinimal.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ query collectionByIdMinimal($id: String!) {
description
id
image
banner
name
type
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ query collectionByIdMinimalWithRoyalty($id: String!) {
description
id
image
banner
name
type
}
Expand Down

0 comments on commit ad9f811

Please sign in to comment.