@financial-times/dotcom-server-navigation 11.3.0 → 12.0.1
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/dist/node/actions.js +1 -2
- package/dist/node/decorateMenuData.js +1 -2
- package/dist/node/editions.js +2 -3
- package/dist/node/index.js +5 -1
- package/dist/node/navigation.d.ts +1 -1
- package/dist/node/navigation.js +8 -8
- package/dist/node/selectMenuDataForEdition.js +1 -2
- package/dist/tsconfig.tsbuildinfo +1 -2885
- package/package.json +2 -2
package/dist/node/actions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSubscribeAction =
|
|
3
|
+
exports.getSubscribeAction = getSubscribeAction;
|
|
4
4
|
function getSubscribeAction() {
|
|
5
5
|
return {
|
|
6
6
|
id: 'subscribe',
|
|
@@ -8,4 +8,3 @@ function getSubscribeAction() {
|
|
|
8
8
|
url: '/products?segmentId=4526c036-7527-ab37-9a29-0b0403fa0b5f'
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
exports.getSubscribeAction = getSubscribeAction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateMenuData =
|
|
3
|
+
exports.decorateMenuData = decorateMenuData;
|
|
4
4
|
const isSelected = (url, currentPath) => {
|
|
5
5
|
return url === currentPath;
|
|
6
6
|
};
|
|
@@ -41,4 +41,3 @@ function cloneMenu(value, currentPath) {
|
|
|
41
41
|
function decorateMenuData(menuData, currentUrl) {
|
|
42
42
|
return cloneMenu(menuData, currentUrl);
|
|
43
43
|
}
|
|
44
|
-
exports.decorateMenuData = decorateMenuData;
|
package/dist/node/editions.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isEdition = isEdition;
|
|
4
|
+
exports.getEditions = getEditions;
|
|
4
5
|
const availableEditions = [
|
|
5
6
|
{
|
|
6
7
|
id: 'uk',
|
|
@@ -17,11 +18,9 @@ const editionIDs = availableEditions.map((edition) => edition.id);
|
|
|
17
18
|
function isEdition(editionID) {
|
|
18
19
|
return editionIDs.includes(editionID);
|
|
19
20
|
}
|
|
20
|
-
exports.isEdition = isEdition;
|
|
21
21
|
function getEditions(currentEdition) {
|
|
22
22
|
return {
|
|
23
23
|
current: availableEditions.find((edition) => edition.id === currentEdition),
|
|
24
24
|
others: availableEditions.filter((edition) => edition.id !== currentEdition)
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
exports.getEditions = getEditions;
|
package/dist/node/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Poller from 'ft-poller';
|
|
2
2
|
import { TNavMenus, TNavMenusForEdition, TNavSubNavigation, TNavEditions, TNavAction } from '@financial-times/dotcom-types-navigation';
|
|
3
|
-
export
|
|
3
|
+
export type TNavOptions = {
|
|
4
4
|
menuUrl?: string;
|
|
5
5
|
subNavigationUrl?: string;
|
|
6
6
|
interval?: number;
|
package/dist/node/navigation.js
CHANGED
|
@@ -15,7 +15,7 @@ const actions_1 = require("./actions");
|
|
|
15
15
|
// Makes the navigation data completely immutable,
|
|
16
16
|
// To modify the data, clone the parts you need to change then modify in your app
|
|
17
17
|
const parseData = (data) => {
|
|
18
|
-
return deep_freeze_1.default(data);
|
|
18
|
+
return (0, deep_freeze_1.default)(data);
|
|
19
19
|
};
|
|
20
20
|
const removeLeadingForwardSlash = (pagePath) => {
|
|
21
21
|
return pagePath.charAt(0) === '/' ? pagePath.substring(1) : pagePath;
|
|
@@ -43,13 +43,13 @@ class Navigation {
|
|
|
43
43
|
}
|
|
44
44
|
async getMenusFor(currentPath, currentEdition = 'uk') {
|
|
45
45
|
const menusData = await this.getMenusData();
|
|
46
|
-
const menusForEdition = selectMenuDataForEdition_1.selectMenuDataForEdition(menusData, currentEdition);
|
|
47
|
-
return decorateMenuData_1.decorateMenuData(menusForEdition, currentPath);
|
|
46
|
+
const menusForEdition = (0, selectMenuDataForEdition_1.selectMenuDataForEdition)(menusData, currentEdition);
|
|
47
|
+
return (0, decorateMenuData_1.decorateMenuData)(menusForEdition, currentPath);
|
|
48
48
|
}
|
|
49
49
|
async getSubNavigationFor(path) {
|
|
50
50
|
const currentPage = removeLeadingForwardSlash(path);
|
|
51
51
|
const subNavigation = `${this.options.subNavigationUrl}/${currentPage}`;
|
|
52
|
-
const response = await node_fetch_1.default(subNavigation);
|
|
52
|
+
const response = await (0, node_fetch_1.default)(subNavigation);
|
|
53
53
|
if (response.ok) {
|
|
54
54
|
const data = await response.json();
|
|
55
55
|
const currentItem = { ...data.item, selected: true };
|
|
@@ -59,19 +59,19 @@ class Navigation {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
throw http_errors_1.default(response.status, `Sub-navigation for ${currentPage} could not be found.`);
|
|
62
|
+
throw (0, http_errors_1.default)(response.status, `Sub-navigation for ${currentPage} could not be found.`);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
getEditionsFor(currentEdition = 'uk') {
|
|
66
|
-
if (editions_1.isEdition(currentEdition)) {
|
|
67
|
-
return editions_1.getEditions(currentEdition);
|
|
66
|
+
if ((0, editions_1.isEdition)(currentEdition)) {
|
|
67
|
+
return (0, editions_1.getEditions)(currentEdition);
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
70
70
|
throw Error(`The provided edition "${currentEdition}" is not a valid edition`);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
getSubscribeAction() {
|
|
74
|
-
return actions_1.getSubscribeAction();
|
|
74
|
+
return (0, actions_1.getSubscribeAction)();
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
exports.Navigation = Navigation;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.selectMenuDataForEdition =
|
|
3
|
+
exports.selectMenuDataForEdition = selectMenuDataForEdition;
|
|
4
4
|
const sharedMenuKeys = [
|
|
5
5
|
'account',
|
|
6
6
|
'anon',
|
|
@@ -24,4 +24,3 @@ function selectMenuDataForEdition(menuData, currentEdition) {
|
|
|
24
24
|
}
|
|
25
25
|
return output;
|
|
26
26
|
}
|
|
27
|
-
exports.selectMenuDataForEdition = selectMenuDataForEdition;
|