Skip to content

feat: collection banner use banner field #11117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 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
Loading