diff --git a/src/components/Metadata.astro b/src/components/Metadata.astro index 7b1303f..c9d93d5 100644 --- a/src/components/Metadata.astro +++ b/src/components/Metadata.astro @@ -41,7 +41,7 @@ if (values.length === 0) return; flex-wrap: wrap; gap: 6px; place-items: center; - translate: 0px 3px; + translate: 0px 2px; &.with-border { & > div, diff --git a/src/pages/[locale]/collectibles/[slug]/_components/PageInfo.astro b/src/pages/[locale]/collectibles/[slug]/_components/PageInfo.astro index 1bb83f8..5f7b46d 100644 --- a/src/pages/[locale]/collectibles/[slug]/_components/PageInfo.astro +++ b/src/pages/[locale]/collectibles/[slug]/_components/PageInfo.astro @@ -54,20 +54,15 @@ const { t } = await getI18n(Astro.locals.currentLocale); diff --git a/src/pages/[locale]/collectibles/[slug]/_components/PriceInfo.astro b/src/pages/[locale]/collectibles/[slug]/_components/PriceInfo.astro new file mode 100644 index 0000000..6ea1f21 --- /dev/null +++ b/src/pages/[locale]/collectibles/[slug]/_components/PriceInfo.astro @@ -0,0 +1,37 @@ +--- +import Metadata from "components/Metadata.astro"; +import { getI18n } from "src/i18n/i18n"; +import { convert } from "src/utils/currencies"; + +interface Props { + price: { + amount: number; + currency: string; + }; +} + +const { price } = Astro.props; +const { formatPrice, t } = await getI18n(Astro.locals.currentLocale); + +const preferredCurrency = Astro.locals.currentCurrency; + +const convertedPrice = { + amount: convert(price.currency, preferredCurrency, price.amount), + currency: preferredCurrency, +}; + +let priceText = price.amount === 0 ? t("collectibles.price.free") : formatPrice(price); + +if (price.amount > 0 && price.currency !== convertedPrice.currency) { + priceText += ` (${formatPrice(convertedPrice)})`; +} +--- + +{/* ------------------------------------------- HTML ------------------------------------------- */} + + diff --git a/src/pages/[locale]/collectibles/[slug]/_components/SizeInfo.astro b/src/pages/[locale]/collectibles/[slug]/_components/SizeInfo.astro index 9d74e20..0c5ee41 100644 --- a/src/pages/[locale]/collectibles/[slug]/_components/SizeInfo.astro +++ b/src/pages/[locale]/collectibles/[slug]/_components/SizeInfo.astro @@ -47,14 +47,10 @@ const { formatInches, formatMillimeters, t } = await getI18n(Astro.locals.curren + diff --git a/src/pages/[locale]/collectibles/[slug]/index.astro b/src/pages/[locale]/collectibles/[slug]/index.astro index 3222695..726609b 100644 --- a/src/pages/[locale]/collectibles/[slug]/index.astro +++ b/src/pages/[locale]/collectibles/[slug]/index.astro @@ -13,16 +13,16 @@ import SubitemSection from "./_components/SubitemSection.astro"; import ContentsSection from "./_components/ContentsSection/ContentsSection.astro"; import { formatInlineTitle, formatLocale, formatRichTextToString } from "src/utils/format"; import AsideLayout from "components/AppLayout/AsideLayout.astro"; -import { convert } from "src/utils/currencies"; import Attributes from "components/Attributes.astro"; import type { Attribute } from "src/utils/attributes"; import { payload } from "src/utils/payload"; import { sizesToSrcset } from "src/utils/img"; import RichText from "components/RichText/RichText.astro"; import SubFilesSection from "./_components/SubFilesSection.astro"; +import PriceInfo from "./_components/PriceInfo.astro"; const slug = Astro.params.slug!; -const { getLocalizedMatch, getLocalizedUrl, t, formatDate, formatPrice } = await getI18n( +const { getLocalizedMatch, getLocalizedUrl, t, formatDate } = await getI18n( Astro.locals.currentLocale ); @@ -116,28 +116,6 @@ if (languages.length > 0) { withBorder: true, }); } - -if (price) { - const preferredCurrency = Astro.locals.currentCurrency; - - const convertedPrice = { - amount: convert(price.currency, preferredCurrency, price.amount), - currency: preferredCurrency, - }; - - let priceText = price.amount === 0 ? t("collectibles.price.free") : formatPrice(price); - - if (price.amount > 0 && price.currency !== convertedPrice.currency) { - priceText += ` (${formatPrice(convertedPrice)})`; - } - - additionalAttributes.push({ - title: t("collectibles.price"), - icon: "material-symbols:sell-outline", - values: [{ name: priceText }], - withBorder: false, - }); -} --- {/* ------------------------------------------- HTML ------------------------------------------- */} @@ -211,6 +189,8 @@ if (price) {
+ {price && } + {size && }