-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
22 changed files
with
2,861 additions
and
316 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": ["airbnb", "airbnb-typescript", "prettier"], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": "latest", | ||
"sourceType": "module", | ||
"project": "./tsconfig.json" | ||
}, | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"@typescript-eslint/no-explicit-any": "error", | ||
"linebreak-style": 0, | ||
"@typescript-eslint/semi": "off", | ||
"react/react-in-jsx-scope": "off", | ||
"react/jsx-props-no-spreading": "off" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"singleQuote": true, | ||
"bracketSpacing": true, | ||
"semi": false, | ||
"trailingComma": "all", | ||
"printWidth": 100, | ||
"jsxBracketSameLine": true, | ||
"arrowParens": "always" | ||
} |
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,8 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
}, | ||
// Add those two lines: | ||
"editor.formatOnSave": true, // Tell VSCode to format files on save | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" // Tell VSCode to use Prettier as default file formatter | ||
} |
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,30 @@ | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations' | ||
import i18nextConfig from '../next-i18next.config' | ||
|
||
export const getI18nPaths = () => | ||
i18nextConfig.i18n.locales.map((lng) => ({ | ||
params: { | ||
locale: lng, | ||
}, | ||
})) | ||
|
||
export const getStaticPaths = () => ({ | ||
fallback: false, | ||
paths: getI18nPaths(), | ||
}) | ||
|
||
export async function getI18nProps(ctx, ns = ['common']) { | ||
const locale = ctx?.params?.locale | ||
let props = { | ||
...(await serverSideTranslations(locale, ns)), | ||
} | ||
return props | ||
} | ||
|
||
export function makeStaticProps(ns = []) { | ||
return async function getStaticProps(ctx) { | ||
return { | ||
props: await getI18nProps(ctx, ns), | ||
} | ||
} | ||
} |
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,7 @@ | ||
import languageDetector from 'next-language-detector' | ||
import i18nextConfig from '../next-i18next.config' | ||
|
||
export default languageDetector({ | ||
supportedLngs: i18nextConfig.i18n.locales, | ||
fallbackLng: i18nextConfig.i18n.defaultLocale, | ||
}) |
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,34 @@ | ||
import { useEffect } from 'react' | ||
import { useRouter } from 'next/router' | ||
import languageDetector from './languageDetector' | ||
|
||
export const useRedirect = (to) => { | ||
const router = useRouter() | ||
to = to || router.asPath | ||
|
||
// language detection | ||
useEffect(() => { | ||
const detectedLng = languageDetector.detect() | ||
if (to.startsWith('/' + detectedLng) && router.route === '/404') { | ||
// prevent endless loop | ||
router.replace('/' + detectedLng + router.route) | ||
return | ||
} | ||
|
||
languageDetector.cache(detectedLng) | ||
router.replace('/' + detectedLng + to) | ||
}) | ||
|
||
return <></> | ||
} | ||
|
||
export const Redirect = () => { | ||
useRedirect() | ||
return <></> | ||
} | ||
|
||
// eslint-disable-next-line react/display-name | ||
export const getRedirect = (to) => () => { | ||
useRedirect(to) | ||
return <></> | ||
} |
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,7 @@ | ||
module.exports = { | ||
i18n: { | ||
defaultLocale: 'de', | ||
locales: ['en', 'de'], | ||
localeDetection: true, | ||
}, | ||
} |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
|
||
module.exports = { | ||
reactStrictMode: true, | ||
swcMinify: true, | ||
} | ||
|
||
module.exports = nextConfig |
Oops, something went wrong.