-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13c4a03
commit 887417f
Showing
29 changed files
with
420 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default async function NotFound() { | ||
// { | ||
// params: { lang }, | ||
// }: { | ||
// params: { lang: Locale }; | ||
// } | ||
// const dictionary = await getDictionary(lang); | ||
|
||
return <>Not fount page.</>; | ||
// return <>{dictionary['ui']['page-not-found']}</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Locale } from '@/shared/config'; | ||
import { Header } from '@/widgets'; | ||
import { getDictionary } from '../../src/shared/config/i18n/dictionaries'; | ||
|
||
export default async function Home({ | ||
params: { lang }, | ||
}: { | ||
params: { lang: Locale }; | ||
}) { | ||
const dictionary = await getDictionary(lang); | ||
const { description, note, title } = dictionary['home-page']; | ||
|
||
return ( | ||
<> | ||
<Header note={note} title={title} description={description} /> | ||
</> | ||
); | ||
} |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { i18n, Locale } from '@/shared/config'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
export function middleware(request: NextRequest) { | ||
const { pathname } = request.nextUrl; | ||
|
||
// `/_next/` and `/api/` are ignored by the watcher, but we need to ignore files in `public` manually | ||
if ( | ||
[ | ||
'/images/light.avif', | ||
'/images/noise.png', | ||
'/images/light-dark.avif', | ||
'/favicon.ico', | ||
].includes(pathname) | ||
) { | ||
return; | ||
} | ||
|
||
if ( | ||
pathname.startsWith(`/${i18n.defaultLocale}/`) || | ||
pathname === `/${i18n.defaultLocale}` | ||
) { | ||
// The incoming request is for /en/whatever, so we'll reDIRECT to /whatever | ||
return NextResponse.redirect( | ||
new URL( | ||
pathname.replace( | ||
`/${i18n.defaultLocale}`, | ||
pathname === `/${i18n.defaultLocale}` ? '/' : '', | ||
), | ||
request.url, | ||
), | ||
); | ||
} | ||
|
||
const pathnameIsMissingLocale = i18n.locales.every( | ||
(locale) => | ||
!pathname.startsWith(`/${locale}/`) && pathname !== `/${locale}`, | ||
); | ||
|
||
if (pathnameIsMissingLocale) { | ||
// Now for EITHER /en or /nl (for example) we're going to tell Next.js that the request is for /en/whatever | ||
// or /nl/whatever, and then reWRITE the request to that it is handled properly. | ||
return NextResponse.rewrite( | ||
new URL( | ||
`/${i18n.defaultLocale}${pathname}${request.nextUrl.search}`, | ||
request.nextUrl.href, | ||
), | ||
); | ||
} | ||
|
||
const requestHeaders = new Headers(request.headers); | ||
requestHeaders.set('x-url', request.url); | ||
|
||
const segments = request.url.split('/')[3]; | ||
const lang = i18n.locales.includes(segments as Locale) | ||
? segments | ||
: i18n.defaultLocale; | ||
requestHeaders.set('x-lang', lang); | ||
|
||
return NextResponse.next({ | ||
request: { | ||
headers: requestHeaders, | ||
}, | ||
}); | ||
} | ||
|
||
export const config = { | ||
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.