@digigov/nextjs 1.1.5-0edebf87 → 1.1.5-85c27c19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/App.tsx CHANGED
@@ -8,16 +8,23 @@ import DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';
8
8
  import type { AppProps } from '@digigov/ui/app/App';
9
9
  import { I18NProvider } from '@digigov/ui/i18n';
10
10
  import { LinkProvider } from '@digigov/ui/navigation/Link';
11
+ import { NextRouter, useRouter } from 'next/router';
11
12
 
12
13
  export interface DigiGOVNextAppProps extends AppProps, WithTranslation {
13
14
  children?: React.ReactNode;
14
15
  t: TFunction;
15
16
  i18n: i18n;
16
17
  ssr: boolean;
18
+ router: NextRouter;
17
19
  }
18
- class DigiGOVNextApp extends App<DigiGOVNextAppProps> {
20
+ class DigiGOVNextAppClass extends App<DigiGOVNextAppProps> {
19
21
  render(): React.ReactElement {
20
- const { Component, pageProps, t, i18n, ssr = false } = this.props;
22
+ const { Component, pageProps, t, i18n, ssr = false, router } = this.props;
23
+ const {locale} = router;
24
+
25
+ if (locale && i18n.language != locale) {
26
+ i18n.changeLanguage(locale);
27
+ }
21
28
  return (
22
29
  <I18NProvider
23
30
  t={(str) => (typeof str === 'string' ? t(str) : str)}
@@ -44,5 +51,10 @@ class DigiGOVNextApp extends App<DigiGOVNextAppProps> {
44
51
  );
45
52
  }
46
53
  }
47
- const DigiGOVNextAppWithTranslation = withTranslation()(DigiGOVNextApp);
48
- export default DigiGOVNextAppWithTranslation;
54
+
55
+ const DigiGOVNextAppWithTranslation = withTranslation()(DigiGOVNextAppClass);
56
+ const DigiGOVNextApp = (props) => {
57
+ const router = useRouter()
58
+ return <DigiGOVNextAppWithTranslation {...props} router={router} />
59
+ }
60
+ export default DigiGOVNextApp;
package/src/Document.tsx CHANGED
@@ -2,20 +2,6 @@
2
2
  import React from 'react';
3
3
  import Document, { Html, Head, Main, NextScript } from 'next/document';
4
4
 
5
- export function Fonts() {
6
- return (
7
- <>
8
- <link
9
- rel="stylesheet"
10
- href="https://fonts.googleapis.com/icon?family=Material+Icons"
11
- />
12
- <link
13
- rel="stylesheet"
14
- href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
15
- />
16
- </>
17
- );
18
- }
19
5
  export default class DigiGOVDocument extends Document {
20
6
  render() {
21
7
  return (
@@ -28,8 +14,6 @@ export default class DigiGOVDocument extends Document {
28
14
  `,
29
15
  }}
30
16
  ></script>
31
- {/* PWA primary color */}
32
- <Fonts />
33
17
  </Head>
34
18
  <body>
35
19
  <Main />
package/src/Image.tsx CHANGED
@@ -3,8 +3,10 @@ import NextImage, { ImageProps } from 'next/image';
3
3
  import { useBasePath } from '@digigov/nextjs/hooks';
4
4
 
5
5
  const Image: React.FC<ImageProps> = ({ src, ...rest }) => {
6
- const basePathSrc = useBasePath(src);
7
- return <NextImage src={basePathSrc} {...rest} />;
6
+ const basePathSrc = useBasePath(typeof src === 'string' ? src : '');
7
+ return (
8
+ <NextImage src={typeof src === 'string' ? basePathSrc : src} {...rest} />
9
+ );
8
10
  };
9
11
 
10
12
  export default Image;
package/src/Link.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import Link from 'next/link';
3
3
  import { useRouter } from 'next/router';
4
- import LinkBase from '@digigov/react-core/LinkBase';
4
+ import {LinkBase} from '@digigov/ui/navigation/Link';
5
5
  import { LinkProps } from '@digigov/ui/navigation/Link';
6
6
 
7
7
  const NextLink: React.ForwardRefRenderFunction<HTMLAnchorElement, LinkProps> = (