From 8fea3ed018d0b6d6ce24d48e5597c4fe53c22c80 Mon Sep 17 00:00:00 2001 From: umidullo Date: Wed, 23 Aug 2023 00:06:25 +0500 Subject: [PATCH] feat: add routing --- pages/_app.tsx | 5 ++++- pages/index.tsx | 5 ++--- pages/info/about.tsx | 15 +++++++++++++++ pages/info/career.tsx | 15 +++++++++++++++ pages/info/contacts.tsx | 15 +++++++++++++++ pages/portfolio/[slug].tsx | 27 +++++++++++++++++++++++++++ pages/portfolio/index.tsx | 15 +++++++++++++++ pages/services/[slug].tsx | 27 +++++++++++++++++++++++++++ pages/services/index.tsx | 15 +++++++++++++++ 9 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 pages/info/about.tsx create mode 100644 pages/info/career.tsx create mode 100644 pages/info/contacts.tsx create mode 100644 pages/portfolio/[slug].tsx create mode 100644 pages/portfolio/index.tsx create mode 100644 pages/services/[slug].tsx create mode 100644 pages/services/index.tsx diff --git a/pages/_app.tsx b/pages/_app.tsx index 1a9f7ad..144a3c2 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -5,6 +5,7 @@ import { appWithTranslation } from 'next-i18next'; import Router from 'next/router'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; +import Layout from '@/components/layout'; NProgress.configure({ showSpinner: false }); @@ -39,7 +40,9 @@ function App({ Component, pageProps }: AppProps) { - + + + ); } diff --git a/pages/index.tsx b/pages/index.tsx index 7e895bb..6339373 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,5 +1,4 @@ import Clients from '@/components/clients'; -import Layout from '@/components/layout'; import Portfolio from '@/components/portfolio'; import Promo from '@/components/promo'; import Services from '@/components/services'; @@ -22,11 +21,11 @@ export default function Home({ posts, }: InferGetServerSidePropsType) { return ( - + <> - + ); } diff --git a/pages/info/about.tsx b/pages/info/about.tsx new file mode 100644 index 0000000..48587fd --- /dev/null +++ b/pages/info/about.tsx @@ -0,0 +1,15 @@ +import Magic from '@/components/magic'; +import { getStaticPropsTranslations } from '@/utils/helpers/i18n'; +import { GetServerSideProps } from 'next'; + +export const getServerSideProps: GetServerSideProps = async (context) => { + return { + props: { + ...(await getStaticPropsTranslations(context.locale ?? 'ru')), + }, + }; +}; + +export default function Page() { + return ; +} diff --git a/pages/info/career.tsx b/pages/info/career.tsx new file mode 100644 index 0000000..48587fd --- /dev/null +++ b/pages/info/career.tsx @@ -0,0 +1,15 @@ +import Magic from '@/components/magic'; +import { getStaticPropsTranslations } from '@/utils/helpers/i18n'; +import { GetServerSideProps } from 'next'; + +export const getServerSideProps: GetServerSideProps = async (context) => { + return { + props: { + ...(await getStaticPropsTranslations(context.locale ?? 'ru')), + }, + }; +}; + +export default function Page() { + return ; +} diff --git a/pages/info/contacts.tsx b/pages/info/contacts.tsx new file mode 100644 index 0000000..48587fd --- /dev/null +++ b/pages/info/contacts.tsx @@ -0,0 +1,15 @@ +import Magic from '@/components/magic'; +import { getStaticPropsTranslations } from '@/utils/helpers/i18n'; +import { GetServerSideProps } from 'next'; + +export const getServerSideProps: GetServerSideProps = async (context) => { + return { + props: { + ...(await getStaticPropsTranslations(context.locale ?? 'ru')), + }, + }; +}; + +export default function Page() { + return ; +} diff --git a/pages/portfolio/[slug].tsx b/pages/portfolio/[slug].tsx new file mode 100644 index 0000000..c8b7c79 --- /dev/null +++ b/pages/portfolio/[slug].tsx @@ -0,0 +1,27 @@ +import Magic from '@/components/magic'; +import { getStaticPropsTranslations } from '@/utils/helpers/i18n'; +import { GetServerSideProps } from 'next'; + +export const getServerSideProps: GetServerSideProps = async (context) => { + if (!context.params) + return { + notFound: true, + }; + + // const data = await fetchData(`/menu/${context.params.slug}`, context.locale); + // if (!data) { + // return { + // notFound: true, + // }; + // } + + return { + props: { + ...(await getStaticPropsTranslations(context.locale ?? 'ru')), + }, + }; +}; + +export default function Page() { + return ; +} diff --git a/pages/portfolio/index.tsx b/pages/portfolio/index.tsx new file mode 100644 index 0000000..48587fd --- /dev/null +++ b/pages/portfolio/index.tsx @@ -0,0 +1,15 @@ +import Magic from '@/components/magic'; +import { getStaticPropsTranslations } from '@/utils/helpers/i18n'; +import { GetServerSideProps } from 'next'; + +export const getServerSideProps: GetServerSideProps = async (context) => { + return { + props: { + ...(await getStaticPropsTranslations(context.locale ?? 'ru')), + }, + }; +}; + +export default function Page() { + return ; +} diff --git a/pages/services/[slug].tsx b/pages/services/[slug].tsx new file mode 100644 index 0000000..c8b7c79 --- /dev/null +++ b/pages/services/[slug].tsx @@ -0,0 +1,27 @@ +import Magic from '@/components/magic'; +import { getStaticPropsTranslations } from '@/utils/helpers/i18n'; +import { GetServerSideProps } from 'next'; + +export const getServerSideProps: GetServerSideProps = async (context) => { + if (!context.params) + return { + notFound: true, + }; + + // const data = await fetchData(`/menu/${context.params.slug}`, context.locale); + // if (!data) { + // return { + // notFound: true, + // }; + // } + + return { + props: { + ...(await getStaticPropsTranslations(context.locale ?? 'ru')), + }, + }; +}; + +export default function Page() { + return ; +} diff --git a/pages/services/index.tsx b/pages/services/index.tsx new file mode 100644 index 0000000..48587fd --- /dev/null +++ b/pages/services/index.tsx @@ -0,0 +1,15 @@ +import Magic from '@/components/magic'; +import { getStaticPropsTranslations } from '@/utils/helpers/i18n'; +import { GetServerSideProps } from 'next'; + +export const getServerSideProps: GetServerSideProps = async (context) => { + return { + props: { + ...(await getStaticPropsTranslations(context.locale ?? 'ru')), + }, + }; +}; + +export default function Page() { + return ; +}