diff --git a/astro.config.mjs b/astro.config.mjs index 22f0c5a..7f1b53a 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -7,6 +7,7 @@ import react from '@astrojs/react' // https://astro.build/config export default defineConfig({ integrations: [tailwind(), react()], + prefetch: true, i18n: { locales: ['ru', 'en'], defaultLocale: 'ru', diff --git a/src/components/CoachCard.astro b/src/components/CoachCard.astro index 6964e71..895766e 100644 --- a/src/components/CoachCard.astro +++ b/src/components/CoachCard.astro @@ -1,21 +1,22 @@ --- -import type { coachesSchema } from '@/content.config' import { useTranslations } from '@/i18n/utils' import { Image } from 'astro:assets' -import type { z } from 'astro:content' +import type { CollectionEntry } from 'astro:content' -type Props = z.infer> & { lang?: string } +type Props = CollectionEntry<'coaches'> & { lang?: string } -const { lang, name, description, image, imageAlt, link } = Astro.props +const { slug, lang, data } = Astro.props +const { name, description, cover, coverAlt } = data const t = useTranslations(lang) +const coachPageLink = `/coaches/${slug}` ---
- + {imageAlt}

{name}

{description &&

{description}

} - { - link && ( -
- {t('coaches.link')} - - ) - } + + {t('coaches.link')} +
diff --git a/src/components/Footer.astro b/src/components/Footer.astro index d0a92c3..9b46f48 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -4,20 +4,12 @@ import { Image } from 'astro:assets' import logoSrc from '@/assets/logo.png' import type { z } from 'astro:content' import type { footerSchema } from '@/content.config' -import type React from 'react' -import { TelegramIcon } from '@/assets/icons/TelegramIcon' -import { InstagramIcon } from '@/assets/icons/InstagramIcon' -import type { IconProps } from '@/assets/icons/types' +import { SocialMediaIcon } from './SocialMediaIcon' type Props = z.infer & { lang?: string } -const SOCIAL_MEDIA_ICONS_MAP: Record> = { - telegram: TelegramIcon, - instagram: InstagramIcon, -} - const { lang, socialMediaLinks } = Astro.props const t = useTranslations(lang) --- @@ -40,11 +32,12 @@ const t = useTranslations(lang) socialMediaLinks && (
{socialMediaLinks.map(({ href, target, icon }) => { - const Icon = SOCIAL_MEDIA_ICONS_MAP[icon] - return ( - + ) })} diff --git a/src/components/ServiceCard.astro b/src/components/ServiceCard.astro index 662bf4f..b5e529d 100644 --- a/src/components/ServiceCard.astro +++ b/src/components/ServiceCard.astro @@ -4,7 +4,7 @@ import type { z } from 'astro:content' type Props = z.infer & { highlighted?: boolean } -const { title, charachteristics, highlighted = false, link } = Astro.props +const { title, description, charachteristics, highlighted = false, link } = Astro.props ---
-
-

{title}

+
+

{title}

+ {description && {description}}
    diff --git a/src/components/SocialMediaIcon.tsx b/src/components/SocialMediaIcon.tsx new file mode 100644 index 0000000..bfc23d3 --- /dev/null +++ b/src/components/SocialMediaIcon.tsx @@ -0,0 +1,22 @@ +import { InstagramIcon } from '@/assets/icons/InstagramIcon' +import { TelegramIcon } from '@/assets/icons/TelegramIcon' +import type { IconProps } from '@/assets/icons/types' + +export const socialMedias = ['telegram', 'instagram'] +export type SocialMedia = (typeof socialMedias)[number] + +type SocialMediaIconProps = { + type: SocialMedia + className?: string +} + +const SOCIAL_MEDIA_ICONS_MAP: Record> = { + telegram: TelegramIcon, + instagram: InstagramIcon, +} + +export const SocialMediaIcon: React.FC = ({ type, className }) => { + const Icon = SOCIAL_MEDIA_ICONS_MAP[type] + + return Icon ? : null +} diff --git a/src/components/header/Header.astro b/src/components/header/Header.astro index 5901624..7ecd4a2 100644 --- a/src/components/header/Header.astro +++ b/src/components/header/Header.astro @@ -1,41 +1,42 @@ --- +import type { TranslationKey } from '@/i18n/ui' import MobileNavigation from './MobileNavigation' import { useTranslations } from '@/i18n/utils' -type Props = { +export type HeaderProps = { + navItems?: Array<{ key: TranslationKey; href: string }> lang?: string } -const { lang } = Astro.props +type Props = HeaderProps -const navItems = [ - { key: 'nav.coaches', href: '#coaches' }, - { key: 'nav.slider', href: '#image-slider' }, - { key: 'nav.services', href: '#services' }, - { key: 'nav.reviews', href: '#reviews' }, - { key: 'nav.contact', href: '#contacts' }, -] as const +const { lang, navItems } = Astro.props const t = useTranslations(lang) ---
    - - - + + { + navItems && ( + <> + + + + ) + }