Skip to content

Commit

Permalink
📈 Set product data for 1st edition in og meta for fb
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Oct 13, 2024
1 parent 5c25644 commit 9bfa4e6
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 41 deletions.
22 changes: 13 additions & 9 deletions src/mixins/nft.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,18 @@ export default {
})
: [defaultEdition];
},
nftEdition() {
let edition;
if (this.editionPriceIndex !== undefined) {
edition = this.nftEditions.find(
e => e.index === this.editionPriceIndex
);
}
if (!edition) {
edition = this.nftEditions.find(item => item.stock > 0);
}
return edition;
},
editionPriceIndex() {
if (this.priceIndex !== undefined) return Number(this.priceIndex);
if (!this.nftIsNFTBook) return undefined;
Expand Down Expand Up @@ -486,15 +498,7 @@ export default {
});
},
nftBookAvailablePriceLabel() {
let edition;
if (this.editionPriceIndex !== undefined) {
edition = this.nftEditions.find(
e => e.index === this.editionPriceIndex
);
}
if (!edition) {
edition = this.nftEditions.find(item => item.stock > 0);
}
const edition = this.nftEdition;
const purchasePrice = edition?.priceLabel;
return purchasePrice;
},
Expand Down
8 changes: 7 additions & 1 deletion src/pages/nft/class/_classId/_nftId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ export default {
description: this.NFTDescription,
brand,
sku: this.classId,
iscn: this.iscnId,
isbn: this.iscnData?.contentMetadata?.isbn,
datePublished: this.iscnData?.recordTimestamp,
bookFormat: this.nftIsNFTBook
Expand All @@ -514,6 +513,13 @@ export default {
''
),
subjectOf: threeDModel,
additionalProperty: [
{
'@type': 'PropertyValue',
propertyID: 'iscn',
value: this.iscnId,
},
],
},
},
];
Expand Down
154 changes: 124 additions & 30 deletions src/pages/nft/class/_classId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,38 @@ export default {
this.$i18n.locale !== 'en' ? 'default-zh.jpg' : 'default.jpg'
}`;
const schemas = [];
const meta = [
{
hid: 'og:title',
property: 'og:title',
content: title,
},
{
hid: 'description',
name: 'description',
content: description,
},
{
hid: 'og:description',
property: 'og:description',
content: description,
},
{
hid: 'og:url',
property: 'og:url',
content: `${EXTERNAL_HOST}${this.$route.path}`,
},
{
hid: 'og:image',
property: 'og:image',
content: ogImage,
},
{
hid: 'likecoin:wallet',
name: 'likecoin:wallet',
content: this.iscnOwner,
},
];
const iscnOwnerPerson = {
'@context': 'http://www.schema.org',
'@type': 'Person',
Expand Down Expand Up @@ -573,7 +605,6 @@ export default {
name: 'Writing NFT',
},
sku: this.classId,
iscn: this.iscnId,
isbn: this.iscnData?.contentMetadata?.isbn,
datePublished: this.iscnData?.recordTimestamp,
url: `${EXTERNAL_HOST}${this.$route.path}`,
Expand All @@ -590,6 +621,13 @@ export default {
}),
},
subjectOf: threeDModel,
additionalProperty: [
{
'@type': 'PropertyValue',
propertyID: 'iscn',
value: this.iscnId,
},
],
});
}
if (this.nftIsNFTBook && this.nftEditions) {
Expand All @@ -608,7 +646,6 @@ export default {
},
author: iscnOwnerPerson,
sku: this.classId,
iscn: this.iscnId,
isbn: this.iscnData?.contentMetadata?.isbn,
inLanguage: this.iscnData?.contentMetadata?.inLanguage,
productGroupID: this.classId,
Expand All @@ -617,6 +654,14 @@ export default {
workExample: [],
hasVariant: [],
variesBy: ['https://schema.org/BookEdition'],
additionalProperty: [
{
'@type': 'PropertyValue',
propertyID: 'iscn',
value: this.iscnId,
},
],
};
this.nftEditions.forEach(e => {
schemas.push({
Expand All @@ -629,7 +674,6 @@ export default {
image: [ogImage],
sku: `${this.classId}-${e.index}`,
inProductGroupWithID: this.classId,
iscn: this.iscnId,
isbn: this.iscnData?.contentMetadata?.isbn,
inLanguage: this.iscnData?.contentMetadata?.inLanguage,
bookFormat: 'https://schema.org/EBook',
Expand All @@ -655,6 +699,13 @@ export default {
}),
},
subjectOf: threeDModel,
additionalProperty: [
{
'@type': 'PropertyValue',
propertyID: 'iscn',
value: this.iscnId,
},
],
});
bookSchema.workExample.push({
'@id': `@${this.classId}-${e.index}`,
Expand All @@ -664,34 +715,77 @@ export default {
});
});
schemas.push(bookSchema);
if (this.nftEdition?.price) {
const e = this.nftEdition;
[
{
hid: 'og:price:amount',
property: 'og:price:amount',
content: e.price,
},
{
hid: 'product:price:amount',
property: 'product:price:amount',
content: e.price,
},
{
hid: 'og:price:currency',
property: 'og:price:currency',
content: 'USD',
},
{
hid: 'product:price:currency',
property: 'product:price:currency',
content: 'USD',
},
{
hid: 'og:availability',
property: 'og:availability',
content: e.stock ? 'in stock' : 'out of stock',
},
{
hid: 'product:brand',
property: 'product:brand',
content: 'NFT Book',
},
{
hide: 'product:locale',
property: 'product:locale',
content: this.$i18n.locale,
},
{
hid: 'product:catalog_id',
property: 'product:catalog_id',
content: `${this.classId}-${e.index}`,
},
{
hid: 'product:retailer_item_id',
property: 'product:retailer_item_id',
content: `${this.classId}-${e.index}`,
},
{
hid: 'product:category',
property: 'product:category',
content: 543542,
},
{
hid: 'product:condition',
property: 'product:condition',
content: 'new',
},
].forEach(m => meta.push(m));
meta.find(m => m.hid === 'og:url').content = `${EXTERNAL_HOST}${
this.$route.path
}?price_index=${e.index}`;
if (this.iscnData?.contentMetadata?.isbn) {
meta.push({
hid: 'product:isbn',
property: 'product:isbn',
content: this.iscnData?.contentMetadata?.isbn,
});
}
}
}
const meta = [
{
hid: 'og:title',
property: 'og:title',
content: title,
},
{
hid: 'description',
name: 'description',
content: description,
},
{
hid: 'og:description',
property: 'og:description',
content: description,
},
{
hid: 'og:image',
property: 'og:image',
content: ogImage,
},
{
hid: 'likecoin:wallet',
name: 'likecoin:wallet',
content: this.iscnOwner,
},
];
if (this.isNFTHidden) {
meta.push({
hid: 'robots',
Expand Down
64 changes: 63 additions & 1 deletion src/pages/nft/collection/_collectionId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ export default {
property: 'og:description',
content: description,
},
{
hid: 'og:url',
property: 'og:url',
content: `${EXTERNAL_HOST}${this.$route.path}`,
},
{
hid: 'og:image',
property: 'og:image',
Expand Down Expand Up @@ -232,8 +238,64 @@ export default {
}),
},
});
[
{
hid: 'og:price:amount',
property: 'og:price:amount',
content: this.collectionPrice,
},
{
hid: 'product:price:amount',
property: 'product:price:amount',
content: this.collectionPrice,
},
{
hid: 'og:price:currency',
property: 'og:price:currency',
content: 'USD',
},
{
hid: 'product:price:currency',
property: 'product:price:currency',
content: 'USD',
},
{
hid: 'og:availability',
property: 'og:availability',
content: this.collection?.stock ? 'in stock' : 'out of stock',
},
{
hid: 'product:brand',
property: 'product:brand',
content: 'NFT Book',
},
{
hide: 'product:locale',
property: 'product:locale',
content: this.$i18n.locale,
},
{
hid: 'product:catalog_id',
property: 'product:catalog_id',
content: this.collectionId,
},
{
hid: 'product:retailer_item_id',
property: 'product:retailer_item_id',
content: this.collectionId,
},
{
hid: 'product:category',
property: 'product:category',
content: 543542,
},
{
hid: 'product:condition',
property: 'product:condition',
content: 'new',
},
].forEach(m => meta.push(m));
}
// ProductCollection
return {
title,
meta,
Expand Down

0 comments on commit 9bfa4e6

Please sign in to comment.