-
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.
✨ Basic oppsett av app router med støtte for flere språk, gjemt bak f…
…eaturetoggling som skjuler visning i prod
- Loading branch information
Showing
11 changed files
with
124 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'server-only'; | ||
|
||
const dictionaries = { | ||
nb: () => import('../../../lib/translations/nb.json').then((module) => module.default), | ||
nn: () => import('../../../lib/translations/nn.json').then((module) => module.default), | ||
}; | ||
|
||
export const getDictionary = async (locale: 'nb' | 'nn' = 'nb') => dictionaries[locale](); |
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,3 @@ | ||
.mainContainer { | ||
/*margin-bottom: var(--a-spacing-32);*/ | ||
} |
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 styles from './layout.module.css'; | ||
|
||
const Layout = ({ children }: Readonly<{ children: React.ReactNode }>) => { | ||
return <main className={styles.mainContainer}>{children}</main>; | ||
}; | ||
|
||
export default Layout; |
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 { Heading } from '@navikt/ds-react'; | ||
import { getDictionary } from 'app/dev/[lang]/dictionaries'; | ||
import { DokumentoversiktMedDatafetching } from 'components/DokumentoversiktNy/DokumentoversiktMedDatafetching'; | ||
import { ForsideIngress } from 'components/Forside/Ingress/ForsideIngress'; | ||
import { PageComponentFlexContainer } from 'components/PageComponentFlexContainer/PageComponentFlexContainer'; | ||
import { isProduction } from 'lib/utils/environments'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
interface PageParams { | ||
lang: 'nb' | 'nn'; | ||
} | ||
|
||
const Page = async ({ params }: Readonly<{ params: Promise<PageParams> }>) => { | ||
const lang = (await params).lang; | ||
const dict = await getDictionary(lang); | ||
|
||
if (isProduction()) { | ||
return notFound(); | ||
} | ||
|
||
return ( | ||
<div> | ||
<PageComponentFlexContainer> | ||
<Heading level="1" size="large" spacing> | ||
{dict.appTittelMedSkille /* TODO: Add shy */} | ||
</Heading> | ||
<ForsideIngress>{dict.appIngress}</ForsideIngress> | ||
</PageComponentFlexContainer> | ||
<DokumentoversiktMedDatafetching /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Page; |
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,28 @@ | ||
import '@navikt/ds-css'; | ||
import { fetchDecoratorReact } from '@navikt/nav-dekoratoren-moduler/ssr'; | ||
import { getEnvironment } from 'lib/utils/environments'; | ||
import Script from 'next/script'; | ||
|
||
export const metadata = { | ||
title: 'Mine AAP', | ||
//description: 'Generated by Next.js', | ||
}; | ||
const RootLayout = async ({ children }: Readonly<{ children: React.ReactNode }>) => { | ||
const Decorator = await fetchDecoratorReact({ env: getEnvironment() }); | ||
|
||
return ( | ||
<html lang="nb"> | ||
<head> | ||
<Decorator.HeadAssets /> | ||
</head> | ||
<body> | ||
<Decorator.Header /> | ||
{children} | ||
<Decorator.Footer /> | ||
<Decorator.Scripts loader={Script} /> | ||
</body> | ||
</html> | ||
); | ||
}; | ||
|
||
export default RootLayout; |
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
28 changes: 28 additions & 0 deletions
28
components/DokumentoversiktNy/DokumentoversiktMedDatafetching.tsx
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,28 @@ | ||
import { Heading, BodyShort, ReadMore } from '@navikt/ds-react'; | ||
import { getDictionary } from 'app/dev/[lang]/dictionaries'; | ||
//import { Dokumentoversikt } from 'components/DokumentoversiktNy/Dokumentoversikt'; | ||
import { PageComponentFlexContainer } from 'components/PageComponentFlexContainer/PageComponentFlexContainer'; | ||
//import { Dokument } from 'lib/types/types'; | ||
//import { hentDokumenterFraOppslag } from 'pages/api/dokumenter'; | ||
|
||
export const DokumentoversiktMedDatafetching = async () => { | ||
//const dokumenter = (await hentDokumenterFraOppslag()) as Dokument[]; | ||
|
||
const dict = await getDictionary('nb'); | ||
|
||
return ( | ||
<PageComponentFlexContainer subtleBackground> | ||
<div style={{ maxWidth: '600px' }}> | ||
<Heading level="2" size="medium" spacing> | ||
{dict.dokumentoversikt.tittel} | ||
</Heading> | ||
<BodyShort spacing>{dict.dokumentoversikt.tekst}</BodyShort> | ||
<ReadMore header={dict.dokumentoversikt.manglendeDokument.header}> | ||
<BodyShort spacing>{dict.dokumentoversikt.manglendeDokument.tekst}</BodyShort> | ||
</ReadMore> | ||
|
||
{/*<Dokumentoversikt dokumenter={dokumenter} />*/} | ||
</div> | ||
</PageComponentFlexContainer> | ||
); | ||
}; |
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,3 @@ | ||
import { DecoratorLocale } from '@navikt/nav-dekoratoren-moduler'; | ||
|
||
export const availableLanguages: DecoratorLocale[] = ['nb', 'nn']; |
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
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,13 @@ | ||
const MOCK_ENVIRONMENTS = ['localhost']; | ||
|
||
export const isMock = () => MOCK_ENVIRONMENTS.includes(process.env.NEXT_PUBLIC_ENVIRONMENT ?? ''); | ||
|
||
export const isProduction = () => process.env.NEXT_PUBLIC_ENVIRONMENT === 'prod'; | ||
|
||
export function getEnvironment(): 'prod' | 'dev' { | ||
if (isProduction()) { | ||
return 'prod'; | ||
} else { | ||
return 'dev'; | ||
} | ||
} |