Skip to content

Commit

Permalink
🧹 seo ammount decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
roiLeo committed Jul 7, 2022
1 parent 7852b5b commit 2edb73d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pages/bsx/gallery/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Component, Vue } from 'nuxt-property-decorator'
import GalleryItem from '@/components/bsx/Gallery/Item/GalleryItem.vue'
import { generateNftImage } from '@/utils/seoImageGenerator'
import { formatBalanceEmptyOnZero } from '@/utils/format/balance'
import { formatBsxBalanceEmptyOnZero } from '@/utils/format/balance'
@Component<GalleryItemPage>({
name: 'GalleryItemPage',
Expand Down Expand Up @@ -51,7 +51,7 @@ export default class GalleryItemPage extends Vue {
get image(): string {
return generateNftImage(
this.currentlyViewedItem.name,
formatBalanceEmptyOnZero(this.currentlyViewedItem.price),
formatBsxBalanceEmptyOnZero(this.currentlyViewedItem.price),
this.currentlyViewedItem.image,
this.currentlyViewedItem.mimeType
)
Expand Down
15 changes: 15 additions & 0 deletions utils/format/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ export const formatBalanceEmptyOnZero = (
? ''
: trimAll(formatBalance(amount, decimals || 12, symbol || 'KSM'))
}

export const formatBsxBalanceEmptyOnZero = (
amount: string,
decimals?: number,
symbol?: string
) => {
return amount === '0'
? ''
: Number(
formatBalance(amount, decimals || 12, symbol || 'KSM')
).toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})
}

0 comments on commit 2edb73d

Please sign in to comment.