diff --git a/src/app/(main)/blog/page.tsx b/src/app/(main)/blog/page.tsx index 97fa346e..20f9599a 100644 --- a/src/app/(main)/blog/page.tsx +++ b/src/app/(main)/blog/page.tsx @@ -14,7 +14,10 @@ export default async function BlogPage() { await queryClient.prefetchQuery({ queryKey: ["articles"], - queryFn: () => api.get("articles").json(), + queryFn: () => + api + .get("articles", { searchParams: { locale: "ru" } }) + .json(), }); return ( diff --git a/src/app/robots.txt b/src/app/robots.txt index 8ec32690..733678c8 100644 --- a/src/app/robots.txt +++ b/src/app/robots.txt @@ -2,6 +2,7 @@ User-agent: * Disallow: /login Disallow: /form Disallow: /policy +Disallow: /privacy-policy Disallow: /a1 Disallow: /CircularProgressbar-path diff --git a/src/components/Layout/Footer.tsx b/src/components/Layout/Footer.tsx index e8a21c07..439487e4 100644 --- a/src/components/Layout/Footer.tsx +++ b/src/components/Layout/Footer.tsx @@ -47,7 +47,7 @@ export function Footer() { - +
@@ -88,11 +88,12 @@ export function ContactLink({ className = "", }: PropsWithChildren<{ href: string; className?: string }>) { return ( - {children} - + ); } diff --git a/src/components/modals/ArticleContentFormModal.tsx b/src/components/modals/ArticleContentFormModal.tsx index 4e7dbcfd..b25601a5 100644 --- a/src/components/modals/ArticleContentFormModal.tsx +++ b/src/components/modals/ArticleContentFormModal.tsx @@ -28,6 +28,7 @@ export function ArticleContentFormModal({ createdAt, drafted, id, + locale, }: IArticle) { const { setModal } = useModalStore(); @@ -40,6 +41,7 @@ export function ArticleContentFormModal({ cardImage, createdAt, drafted, + locale, }, }); @@ -84,6 +86,7 @@ export function ArticleContentFormModal({ drafted, posterImage, id, + locale, }} /> ) diff --git a/src/components/modals/ArticleFormModal.tsx b/src/components/modals/ArticleFormModal.tsx index 3f7b8200..bedb0a24 100644 --- a/src/components/modals/ArticleFormModal.tsx +++ b/src/components/modals/ArticleFormModal.tsx @@ -5,6 +5,7 @@ import { useModalStore } from "@/stores/useModalStore"; import { IArticle } from "@/types/IArticle"; import { CheckboxesGroup } from "@/ui/CheckboxesGroup"; import { TextInput } from "@/ui/TextInput"; +import { LocaleSwitch } from "@/ui/LocaleSwitch"; import { FormProvider, useForm, useWatch } from "react-hook-form"; import { ImageUploader } from "../ImageUploader"; // import { ArticleContentFormModal } from "./ArticleContentFormModal"; @@ -39,6 +40,7 @@ export function ArticleFormModal({ blocks: [], tags: [], drafted: true, + locale: "ru", }, mode: "onChange", }); @@ -51,9 +53,9 @@ export function ArticleFormModal({ setModal(); } - const { handleSubmit, getValues, control } = form; + const { handleSubmit, getValues, control, setValue } = form; - const { title, tags, cardImage, posterImage } = useWatch({ control }); + const { title, tags, cardImage, posterImage, locale } = useWatch({ control }); async function handleSave(drafted: boolean) { await mutateAsync({ @@ -101,7 +103,7 @@ export function ArticleFormModal({ name="cardImage" label="Загрузите или перетащите изображение для превью (рекомендованнный размер 1080/1080 px)" /> -
+
@@ -116,6 +118,10 @@ export function ArticleFormModal({ name="posterImage" label="Загрузите или перетащите изображение для превью (рекомендованнный размер 1080/1080 px)" /> + setValue("locale", newLocale)} + />
diff --git a/src/components/pages/BlogPage/ArticleCard.tsx b/src/components/pages/BlogPage/ArticleCard.tsx index d3e974dc..0597cc82 100644 --- a/src/components/pages/BlogPage/ArticleCard.tsx +++ b/src/components/pages/BlogPage/ArticleCard.tsx @@ -16,6 +16,7 @@ export function ArticleCard({ posterImage, createdAt, slug, + locale, className, }: IArticle & { className?: string }) { const params = useSearchParams(); @@ -58,6 +59,7 @@ export function ArticleCard({ drafted, posterImage, createdAt, + locale, }} />
diff --git a/src/queries/getArticles.ts b/src/queries/getArticles.ts index a1d3f6db..65afb2b5 100644 --- a/src/queries/getArticles.ts +++ b/src/queries/getArticles.ts @@ -4,7 +4,8 @@ import { queryOptions, useQuery } from '@tanstack/react-query'; export const queryArticlesOptions = { queryKey: ['articles'], - queryFn: () => api.get('articles').json(), + queryFn: () => + api.get('articles', { searchParams: { locale: "ru" } }).json(), }; export function useGetArticlesQuery(tags?: string | string[]) { @@ -12,18 +13,17 @@ export function useGetArticlesQuery(tags?: string | string[]) { queryOptions( tags && tags.length > 0 ? { - queryKey: ['articles', tags], - queryFn: () => - api - .get( - `articles?${ - Array.isArray(tags) - ? tags.map((tag) => `tags=${tag}`).join('&') - : 'tags=' + tags - }` - ) - .json(), - } + queryKey: ['articles', tags], + queryFn: () => + api + .get( + `articles?${Array.isArray(tags) + ? tags.map((tag) => `tags=${tag}`).join('&') + : 'tags=' + tags + }&locale=ru` + ) + .json(), + } : queryArticlesOptions ) ); diff --git a/src/types/IArticle.ts b/src/types/IArticle.ts index cc3aa157..cbd5f705 100644 --- a/src/types/IArticle.ts +++ b/src/types/IArticle.ts @@ -44,4 +44,5 @@ export interface IArticle { drafted: boolean; slug?: string; blocks: Block[]; + locale: 'ru' | 'en'; } diff --git a/src/ui/LocaleSwitch.tsx b/src/ui/LocaleSwitch.tsx new file mode 100644 index 00000000..922bc34d --- /dev/null +++ b/src/ui/LocaleSwitch.tsx @@ -0,0 +1,64 @@ +import { motion } from "framer-motion"; + +interface LocaleSwitchProps { + value: "ru" | "en"; + onChange: (locale: "ru" | "en") => void; +} + +export function LocaleSwitch({ value, onChange }: LocaleSwitchProps) { + const handleToggle = () => { + onChange(value === "ru" ? "en" : "ru"); + }; + + return ( +
+ +
+ + + {value === "ru" ? "RU" : "EN"} + + + +
+
+ + RU + +
+
+ + EN + +
+
+
+
+ ); +}