@digigov/nextjs 0.6.2 → 0.6.3-alpha
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/.eslintrc.js +3 -0
- package/.prettierrc.js +3 -0
- package/.rush/temp/package-deps_build.json +21 -0
- package/.rush/temp/shrinkwrap-deps.json +334 -0
- package/CHANGELOG.json +918 -0
- package/{App.js → dist/App.js} +0 -0
- package/dist/CHANGELOG.md +248 -0
- package/{Document.js → dist/Document.js} +0 -0
- package/{Image.js → dist/Image.js} +0 -0
- package/{LICENSE → dist/LICENSE} +0 -0
- package/{Link.js → dist/Link.js} +0 -0
- package/dist/README.md +52 -0
- package/{es → dist/es}/App.js +0 -0
- package/{es → dist/es}/Document.js +0 -0
- package/{es → dist/es}/Image.js +0 -0
- package/{es → dist/es}/Link.js +0 -0
- package/{es → dist/es}/hooks.js +0 -0
- package/{es → dist/es}/i18n.js +0 -0
- package/{es → dist/es}/index.js +0 -0
- package/{esm → dist/esm}/App.js +0 -0
- package/{esm → dist/esm}/Document.js +0 -0
- package/{esm → dist/esm}/Image.js +0 -0
- package/{esm → dist/esm}/Link.js +0 -0
- package/{esm → dist/esm}/hooks.js +0 -0
- package/{esm → dist/esm}/i18n.js +0 -0
- package/{esm → dist/esm}/index.js +0 -0
- package/{hooks.js → dist/hooks.js} +0 -0
- package/{i18n.js → dist/i18n.js} +0 -0
- package/{index.js → dist/index.js} +0 -0
- package/{libs → dist/libs}/nextjs/src/App.d.ts +0 -0
- package/{libs → dist/libs}/nextjs/src/Document.d.ts +0 -0
- package/{libs → dist/libs}/nextjs/src/Image.d.ts +0 -0
- package/{libs → dist/libs}/nextjs/src/Link.d.ts +0 -0
- package/{libs → dist/libs}/nextjs/src/hooks.d.ts +0 -0
- package/{libs → dist/libs}/nextjs/src/i18n.d.ts +0 -0
- package/{libs → dist/libs}/nextjs/src/index.d.ts +0 -0
- package/{libs → dist/libs}/ui/src/app/App.d.ts +0 -0
- package/{libs → dist/libs}/ui/src/app/i18n.d.ts +0 -0
- package/{libs → dist/libs}/ui/src/core/Link/index.d.ts +0 -0
- package/{libs → dist/libs}/ui/src/locales/el.d.ts +1 -1
- package/{libs-ui → dist/libs-ui}/react-core/src/Base/index.d.ts +0 -0
- package/{libs-ui → dist/libs-ui}/react-core/src/Link/index.d.ts +0 -0
- package/dist/package.json +26 -0
- package/nextjs.build.log +17 -0
- package/package.json +38 -25
- package/src/App.tsx +52 -0
- package/src/Document.tsx +86 -0
- package/src/Image.tsx +10 -0
- package/src/Link.tsx +33 -0
- package/src/hooks.ts +6 -0
- package/src/i18n.tsx +18 -0
- package/src/index.ts +0 -0
- package/tsconfig.json +14 -0
package/src/Link.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LinkProps } from '@digigov/ui/core/Link';
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import CoreLink from '@digigov/react-core/Link';
|
|
5
|
+
|
|
6
|
+
const NextLink: React.ForwardRefRenderFunction<HTMLAnchorElement, LinkProps> = (
|
|
7
|
+
props,
|
|
8
|
+
ref
|
|
9
|
+
) => {
|
|
10
|
+
const { href, ...other } = props;
|
|
11
|
+
const isExternalLink =
|
|
12
|
+
//check if url has a file extension
|
|
13
|
+
/^(?:[a-z]+:)?\/\/|.pdf|.docx?|.xlsx?/i.test(href || '') ||
|
|
14
|
+
// or if props has a target or rel
|
|
15
|
+
other.target === '_blank';
|
|
16
|
+
|
|
17
|
+
if (isExternalLink) {
|
|
18
|
+
return (
|
|
19
|
+
<CoreLink ref={ref} href={href || '#'} {...other}>
|
|
20
|
+
{props.children}
|
|
21
|
+
</CoreLink>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return (
|
|
25
|
+
<Link href={href || '#'} {...other}>
|
|
26
|
+
<CoreLink ref={ref} {...other}>
|
|
27
|
+
{props.children}
|
|
28
|
+
</CoreLink>
|
|
29
|
+
</Link>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default React.forwardRef(NextLink);
|
package/src/hooks.ts
ADDED
package/src/i18n.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import i18n, { Resource, TFunction } from 'i18next';
|
|
2
|
+
import { initReactI18next } from 'react-i18next';
|
|
3
|
+
|
|
4
|
+
export default function initI18n(
|
|
5
|
+
resources: Resource,
|
|
6
|
+
language = 'el'
|
|
7
|
+
): Promise<TFunction> {
|
|
8
|
+
return i18n
|
|
9
|
+
.use(initReactI18next) // passes i18n down to react-i18next
|
|
10
|
+
.init({
|
|
11
|
+
resources: resources,
|
|
12
|
+
lng: language,
|
|
13
|
+
keySeparator: '.', // we use keys in form messages.welcome
|
|
14
|
+
interpolation: {
|
|
15
|
+
escapeValue: false, // react already safes from xss
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
File without changes
|