@arcblock/result-html-pages 2.5.48 → 2.5.49

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/README.md CHANGED
@@ -13,7 +13,7 @@ render({ status: '403' }) // => 403 page
13
13
  render({ status: '500' }) // => 500 page
14
14
  render({ status: 'error' }) // => error page
15
15
  render({ status: 'maintenance' }) // => maintenance page
16
- render({ status: 'coming-soon' }) // => coming-soon page
16
+ render({ status: 'comingSoon' }) // => comingSoon page
17
17
  render({ status: 'info', title: 'Here is a info message' }) // => info page
18
18
  render({ title: '...', description: '...', icon: '...' }) // => custom result page
19
19
  ```
package/lib/index.js CHANGED
@@ -41,10 +41,11 @@ const renderHandler = _ref => {
41
41
  } = _ref,
42
42
  rest = _objectWithoutProperties(_ref, _excluded);
43
43
 
44
+ const translation = _translations.default[locale] || _translations.default.en;
44
45
  return _template.default.render(_objectSpread({
45
46
  icon,
46
- title: _translations.default[locale][type].title,
47
- description: _translations.default[locale][type].description
47
+ title: translation[type].title,
48
+ description: translation[type].description
48
49
  }, rest));
49
50
  };
50
51
 
@@ -121,14 +122,14 @@ const renderers = {
121
122
  icon: _icons.InfoIcon
122
123
  }, rest));
123
124
  },
124
- 'coming-soon': _ref8 => {
125
+ comingSoon: _ref8 => {
125
126
  let {
126
127
  locale = 'en'
127
128
  } = _ref8,
128
129
  rest = _objectWithoutProperties(_ref8, _excluded8);
129
130
 
130
131
  return renderHandler(_objectSpread({
131
- type: 'coming-soon',
132
+ type: 'comingSoon',
132
133
  locale,
133
134
  icon: _icons.InfoIcon
134
135
  }, rest));
@@ -30,7 +30,7 @@ var _default = {
30
30
  title: 'Offline for maintenance',
31
31
  description: 'This app is undergoing maintenance right now. Please check back later.'
32
32
  },
33
- 'coming-soon': {
33
+ comingSoon: {
34
34
  title: 'Coming Soon',
35
35
  description: "Our website is under construction. We'll be here soon with our new website."
36
36
  }
@@ -60,7 +60,7 @@ var _default = {
60
60
  title: '维护中',
61
61
  description: '应用程序正在进行维护。请稍后再查看。'
62
62
  },
63
- 'coming-soon': {
63
+ comingSoon: {
64
64
  title: '即将上线',
65
65
  description: '我们的网站正在建设中。我们很快就会在这里推出我们的新网站。'
66
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/result-html-pages",
3
- "version": "2.5.48",
3
+ "version": "2.5.49",
4
4
  "description": "This package provide a function that generates html code for common error pages such as 404, 500, etc.",
5
5
  "keywords": [
6
6
  "arcblock",
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "scripts": {
19
19
  "lint": "eslint src tests",
20
+ "lint:fix": "npm run lint -- --fix",
20
21
  "build": "babel src --out-dir lib --copy-files --no-copy-ignored",
21
22
  "watch": "babel src --out-dir lib -w --copy-files --no-copy-ignored",
22
23
  "precommit": "CI=1 npm run lint",
@@ -39,5 +40,5 @@
39
40
  "eslint-plugin-react-hooks": "^4.6.0",
40
41
  "jest": "^28.1.3"
41
42
  },
42
- "gitHead": "79c5d91c07cd0d7c76286b9865d902a27acc163f"
43
+ "gitHead": "984f01cb1503cac77e52885893a9f50269f3da91"
43
44
  }
package/src/index.js CHANGED
@@ -2,13 +2,15 @@ import template from './template';
2
2
  import translations from './translations';
3
3
  import { ErrorIcon, InfoIcon } from './icons';
4
4
 
5
- const renderHandler = ({ type, locale, icon, ...rest }) =>
6
- template.render({
5
+ const renderHandler = ({ type, locale, icon, ...rest }) => {
6
+ const translation = translations[locale] || translations.en;
7
+ return template.render({
7
8
  icon,
8
- title: translations[locale][type].title,
9
- description: translations[locale][type].description,
9
+ title: translation[type].title,
10
+ description: translation[type].description,
10
11
  ...rest,
11
12
  });
13
+ };
12
14
 
13
15
  const renderers = {
14
16
  404: ({ locale = 'en', ...rest }) => renderHandler({ type: 404, locale, icon: ErrorIcon, ...rest }),
@@ -17,8 +19,7 @@ const renderers = {
17
19
  502: ({ locale = 'en', ...rest }) => renderHandler({ type: 502, locale, icon: ErrorIcon, ...rest }),
18
20
  error: ({ locale = 'en', ...rest }) => renderHandler({ type: 'error', locale, icon: ErrorIcon, ...rest }),
19
21
  maintenance: ({ locale = 'en', ...rest }) => renderHandler({ type: 'maintenance', locale, icon: InfoIcon, ...rest }),
20
- 'coming-soon': ({ locale = 'en', ...rest }) =>
21
- renderHandler({ type: 'coming-soon', locale, icon: InfoIcon, ...rest }),
22
+ comingSoon: ({ locale = 'en', ...rest }) => renderHandler({ type: 'comingSoon', locale, icon: InfoIcon, ...rest }),
22
23
  info: (props) => {
23
24
  return template.render({
24
25
  icon: InfoIcon,
@@ -24,7 +24,7 @@ export default {
24
24
  title: 'Offline for maintenance',
25
25
  description: 'This app is undergoing maintenance right now. Please check back later.',
26
26
  },
27
- 'coming-soon': {
27
+ comingSoon: {
28
28
  title: 'Coming Soon',
29
29
  description: "Our website is under construction. We'll be here soon with our new website.",
30
30
  },
@@ -55,7 +55,7 @@ export default {
55
55
  title: '维护中',
56
56
  description: '应用程序正在进行维护。请稍后再查看。',
57
57
  },
58
- 'coming-soon': {
58
+ comingSoon: {
59
59
  title: '即将上线',
60
60
  description: '我们的网站正在建设中。我们很快就会在这里推出我们的新网站。',
61
61
  },