refactor: extract the price formatter

This commit is contained in:
Oliver Davies 2023-10-23 00:50:08 +01:00
parent 1aa45f9270
commit fe032622fa
2 changed files with 8 additions and 6 deletions

View file

@ -5,14 +5,9 @@ title: Products and Services
import ListingPage from "~/components/ListingPage.astro"; import ListingPage from "~/components/ListingPage.astro";
import _ from "lodash"; import _ from "lodash";
import priceFormatter from "~/price-formatter";
import products from "~/products.json"; import products from "~/products.json";
export const priceFormatter = new Intl.NumberFormat('en-GB', {
currency: 'GBP',
maximumSignificantDigits: 2,
style: 'currency',
});
<div class="space-y-12"> <div class="space-y-12">
{products.map((product) => ( {products.map((product) => (
<article> <article>

7
src/price-formatter.ts Normal file
View file

@ -0,0 +1,7 @@
const priceFormatter = new Intl.NumberFormat('en-GB', {
currency: 'GBP',
maximumSignificantDigits: 2,
style: 'currency',
});
export default priceFormatter;