From 2f26ad5464d564f08be03a114d29fa24e4862304 Mon Sep 17 00:00:00 2001 From: Salam-vsem Date: Wed, 14 May 2025 01:15:30 +0300 Subject: [PATCH] images optimizations --- astro.config.mjs | 8 +++--- src/components/CoachCard.astro | 13 ++++++++-- src/components/Hero.astro | 7 ++++- src/components/Reviews.tsx | 37 ++++++++++++++++---------- src/components/Section.astro | 5 +--- src/components/ServiceCard.astro | 8 +++--- src/components/swiper/NavButtons.tsx | 2 +- src/components/swiper/Swiper.tsx | 13 +++++----- src/components/swiper/index.ts | 2 +- src/constants/images.ts | 23 ++++++++++++++++ src/i18n/utils.ts | 14 +++++----- src/libs/image.ts | 7 +++++ src/pages/index.astro | 39 ++++++++++++++++++++++------ tsconfig.json | 15 +++-------- 14 files changed, 130 insertions(+), 63 deletions(-) create mode 100644 src/constants/images.ts create mode 100644 src/libs/image.ts diff --git a/astro.config.mjs b/astro.config.mjs index 3383b73..22f0c5a 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,8 +1,8 @@ // @ts-check -import { defineConfig } from 'astro/config'; -import tailwind from '@astrojs/tailwind'; +import { defineConfig } from 'astro/config' +import tailwind from '@astrojs/tailwind' -import react from '@astrojs/react'; +import react from '@astrojs/react' // https://astro.build/config export default defineConfig({ @@ -14,4 +14,4 @@ export default defineConfig({ prefixDefaultLocale: false, }, }, -}); \ No newline at end of file +}) diff --git a/src/components/CoachCard.astro b/src/components/CoachCard.astro index 85a383d..6964e71 100644 --- a/src/components/CoachCard.astro +++ b/src/components/CoachCard.astro @@ -12,14 +12,23 @@ const t = useTranslations(lang)
- {imageAlt} + {imageAlt}

{name}

{description &&

{description}

} { link && ( - + {t('coaches.link')} ) diff --git a/src/components/Hero.astro b/src/components/Hero.astro index 7143ef8..0f214dc 100644 --- a/src/components/Hero.astro +++ b/src/components/Hero.astro @@ -27,6 +27,11 @@ const { title, description, cta, image, imageAlt } = Astro.props }
diff --git a/src/components/Reviews.tsx b/src/components/Reviews.tsx index 167aa61..c44e033 100644 --- a/src/components/Reviews.tsx +++ b/src/components/Reviews.tsx @@ -6,10 +6,15 @@ import 'swiper/css/scrollbar' import { Mousewheel, Scrollbar } from 'swiper/modules' import StarIconSrc from '@/assets/icons/StarIcon.svg' import { useTranslations } from '@/i18n/utils' +import type { GetImageResult } from 'astro' type Review = z.infer> +type Author = Review['author'] +export type OptimizedReview = Omit & { + author: Omit & { image?: ImportAttributes } +} type ReviewsProps = { - reviews: Review[] + reviews: OptimizedReview[] lang?: string } @@ -36,7 +41,7 @@ export const Reviews: React.FC = ({ reviews, lang }) => { }, }} > - {reviews.map((review, index) => ( + {reviews.map(({ review, author }, index) => (
@@ -51,20 +56,24 @@ export const Reviews: React.FC = ({ reviews, lang }) => { ))}
- {review.review} + {review}
-
- {review.author.imageAlt} -
- {review.author.name} - {review.author.description} + {author && ( +
+ {author.image && ( + + )} +
+ {author.name} + {author.description} +
-
+ )}
))} diff --git a/src/components/Section.astro b/src/components/Section.astro index 9672387..c549cd1 100644 --- a/src/components/Section.astro +++ b/src/components/Section.astro @@ -12,10 +12,7 @@ const { title, description, className, id } = Astro.props ---
{ diff --git a/src/components/ServiceCard.astro b/src/components/ServiceCard.astro index 193d08b..662bf4f 100644 --- a/src/components/ServiceCard.astro +++ b/src/components/ServiceCard.astro @@ -9,7 +9,7 @@ const { title, charachteristics, highlighted = false, link } = Astro.props
{ charachteristics?.map((charachteristic) => ( -
  • +
  • {charachteristic.text} - {charachteristic.price && } + {charachteristic.price && ( + + )}
  • )) } diff --git a/src/components/swiper/NavButtons.tsx b/src/components/swiper/NavButtons.tsx index 606ffa6..ecdd8d1 100644 --- a/src/components/swiper/NavButtons.tsx +++ b/src/components/swiper/NavButtons.tsx @@ -13,7 +13,7 @@ export const NavButton: React.FC = ({ iconSrc, ...buttonProps }) => {