@alpaca-headless/alpaca-headless-nextjs 1.0.2808 → 1.0.2810
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/cjs/components/Picture.js +61 -40
- package/dist/cjs/graphQLTypes.js +2 -0
- package/dist/cjs/index.js +14 -0
- package/dist/cjs/loadRouteData.js +2 -0
- package/dist/cjs/mediaProtection.js +53 -0
- package/dist/esm/components/Picture.js +62 -41
- package/dist/esm/graphQLTypes.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loadRouteData.js +2 -0
- package/dist/esm/mediaProtection.js +46 -0
- package/package.json +1 -1
- package/types/alpacaContext.d.ts +1 -0
- package/types/components/Picture.d.ts +1 -0
- package/types/fieldTypes.d.ts +14 -2
- package/types/graphQLTypes.d.ts +24 -0
- package/types/index.d.ts +1 -0
- package/types/loadRouteData.d.ts +9 -0
- package/types/mediaProtection.d.ts +2 -0
|
@@ -13,6 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.Picture = void 0;
|
|
15
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const mediaProtection_1 = require("../mediaProtection");
|
|
16
17
|
// const addClassName = (otherAttrs: { [key: string]: unknown }): void => {
|
|
17
18
|
// if (otherAttrs.class) {
|
|
18
19
|
// // if any classes are defined properly already
|
|
@@ -27,63 +28,83 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
27
28
|
// }
|
|
28
29
|
// };
|
|
29
30
|
const Picture = (_a) => {
|
|
30
|
-
var _b, _c, _d, _e;
|
|
31
|
-
var { field, imageParams, sources, defaultVariant } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant"]);
|
|
31
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
32
|
+
var { field, imageParams, sources, defaultVariant, renderJsonLinkedData } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant", "renderJsonLinkedData"]);
|
|
32
33
|
if (!field)
|
|
33
|
-
return;
|
|
34
|
-
const variants = (_b = field
|
|
35
|
-
const img = (_d = (_c = field
|
|
36
|
-
const attrs = Object.assign(
|
|
34
|
+
return null;
|
|
35
|
+
const variants = (_b = field.value) === null || _b === void 0 ? void 0 : _b.variants;
|
|
36
|
+
const img = (_d = (_c = field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
|
|
37
|
+
const attrs = Object.assign({ src: img === null || img === void 0 ? void 0 : img.src }, otherProps);
|
|
38
|
+
const video = img === null || img === void 0 ? void 0 : img.videoUrl;
|
|
39
|
+
const videoAttr = Object.assign({ src: video }, otherProps);
|
|
37
40
|
if (!(sources === null || sources === void 0 ? void 0 : sources.length)) {
|
|
38
|
-
return (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt:
|
|
41
|
+
return (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt: (_f = field.value) === null || _f === void 0 ? void 0 : _f.alt }));
|
|
39
42
|
}
|
|
40
43
|
else {
|
|
41
|
-
return ((0, jsx_runtime_1.jsxs)("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (source.widths && source.widths.length) {
|
|
47
|
-
const getScaledImage = (variant, width) => {
|
|
48
|
-
if (width > variant.width)
|
|
49
|
-
return { src: variant.src, width: 0 };
|
|
50
|
-
else
|
|
51
|
-
return { src: variant.src + "&mw=" + width, width: width };
|
|
52
|
-
};
|
|
53
|
-
let scaledImages = source.widths.map((x) => getScaledImage(variant, x));
|
|
54
|
-
srcSet = "";
|
|
55
|
-
for (let w = 0; w < scaledImages.length; w++) {
|
|
56
|
-
if (srcSet.length)
|
|
57
|
-
srcSet = srcSet + ", ";
|
|
58
|
-
srcSet += scaledImages[w].src + " " + source.widths[w] + "w";
|
|
59
|
-
if (scaledImages[w].width === 0)
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
if (source.width) {
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
|
|
45
|
+
const variant = variants === null || variants === void 0 ? void 0 : variants.find((v) => v.name.toLowerCase() == source.variant.toLowerCase());
|
|
46
|
+
if (!variant)
|
|
47
|
+
return;
|
|
48
|
+
let srcSet = (0, mediaProtection_1.hashImageUrl)(variant.src);
|
|
65
49
|
const getScaledImage = (variant, width) => {
|
|
66
50
|
if (width > variant.width)
|
|
67
51
|
return { src: variant.src, width: 0 };
|
|
68
52
|
else
|
|
69
|
-
return { src: variant.src +
|
|
53
|
+
return { src: variant.src + `${variant.src.includes('?') ? '&' : '?'}mw=` + width, width: width };
|
|
70
54
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
|
|
55
|
+
if (source.widths && source.widths.length) {
|
|
56
|
+
let scaledImages = source.widths.map((x) => getScaledImage(variant, x));
|
|
74
57
|
srcSet = "";
|
|
75
58
|
for (let w = 0; w < scaledImages.length; w++) {
|
|
76
59
|
if (srcSet.length)
|
|
77
60
|
srcSet = srcSet + ", ";
|
|
78
|
-
srcSet +=
|
|
61
|
+
srcSet +=
|
|
62
|
+
(0, mediaProtection_1.hashImageUrl)(scaledImages[w].src) +
|
|
63
|
+
" " +
|
|
64
|
+
source.widths[w] +
|
|
65
|
+
"w";
|
|
79
66
|
if (scaledImages[w].width === 0)
|
|
80
67
|
break;
|
|
81
68
|
}
|
|
82
69
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
70
|
+
else {
|
|
71
|
+
if (source.width) {
|
|
72
|
+
srcSet = (0, mediaProtection_1.hashImageUrl)(getScaledImage(variant, source.width).src);
|
|
73
|
+
if (source.scales) {
|
|
74
|
+
let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
|
|
75
|
+
srcSet = "";
|
|
76
|
+
for (let w = 0; w < scaledImages.length; w++) {
|
|
77
|
+
if (srcSet.length)
|
|
78
|
+
srcSet = srcSet + ", ";
|
|
79
|
+
srcSet +=
|
|
80
|
+
(0, mediaProtection_1.hashImageUrl)(scaledImages[w].src) +
|
|
81
|
+
" " +
|
|
82
|
+
source.scales[w] +
|
|
83
|
+
"x";
|
|
84
|
+
if (scaledImages[w].width === 0)
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return ((0, jsx_runtime_1.jsx)("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
|
|
91
|
+
}), (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt: (_g = field.value) === null || _g === void 0 ? void 0 : _g.alt }))] }), renderJsonLinkedData && !video ? (0, jsx_runtime_1.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
92
|
+
__html: JSON.stringify({
|
|
93
|
+
"@context": "http://schema.org",
|
|
94
|
+
"@type": "ImageObject",
|
|
95
|
+
"image": img === null || img === void 0 ? void 0 : img.src,
|
|
96
|
+
"description": (_h = field.value) === null || _h === void 0 ? void 0 : _h.alt,
|
|
97
|
+
"name": (_j = field.value) === null || _j === void 0 ? void 0 : _j.name
|
|
98
|
+
})
|
|
99
|
+
} }) : null, video && (0, jsx_runtime_1.jsx)("video", Object.assign({}, videoAttr)), renderJsonLinkedData && video ? (0, jsx_runtime_1.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
100
|
+
__html: JSON.stringify({
|
|
101
|
+
"@context": "http://schema.org",
|
|
102
|
+
"@type": "VideoObject",
|
|
103
|
+
"contentUrl": img === null || img === void 0 ? void 0 : img.src,
|
|
104
|
+
"description": (_k = field.value) === null || _k === void 0 ? void 0 : _k.alt,
|
|
105
|
+
"name": (_l = field.value) === null || _l === void 0 ? void 0 : _l.name
|
|
106
|
+
})
|
|
107
|
+
} }) : null] }));
|
|
87
108
|
}
|
|
88
109
|
};
|
|
89
110
|
exports.Picture = Picture;
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,12 +10,26 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.GraphQLTypes = void 0;
|
|
17
30
|
__exportStar(require("./layoutData"), exports);
|
|
18
31
|
__exportStar(require("./loadRouteData"), exports);
|
|
19
32
|
__exportStar(require("./components"), exports);
|
|
20
33
|
__exportStar(require("./alpacaContext"), exports);
|
|
21
34
|
__exportStar(require("./fieldTypes"), exports);
|
|
35
|
+
exports.GraphQLTypes = __importStar(require("./graphQLTypes"));
|
|
@@ -30,6 +30,7 @@ const fetchRouteData = (0, react_1.cache)((path, host, mode, itemId, language) =
|
|
|
30
30
|
headers: {
|
|
31
31
|
"Content-Type": "application/json",
|
|
32
32
|
Cookie: (0, headers_1.cookies)().toString(),
|
|
33
|
+
"x-api-key": process.env.API_KEY,
|
|
33
34
|
},
|
|
34
35
|
next: {
|
|
35
36
|
tags: ["pages"],
|
|
@@ -64,6 +65,7 @@ const fetchRouteData = (0, react_1.cache)((path, host, mode, itemId, language) =
|
|
|
64
65
|
site: data.site,
|
|
65
66
|
pageEditing: true,
|
|
66
67
|
pageState: "",
|
|
68
|
+
database: data.page.database,
|
|
67
69
|
};
|
|
68
70
|
context.fields = data.page.fields;
|
|
69
71
|
context.dictionary = yield loadDictionary(context.pageContext.site.name, context.pageContext.language, mode);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.hashImageUrl = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
require("url");
|
|
9
|
+
const protectedParams = [
|
|
10
|
+
"w",
|
|
11
|
+
"h",
|
|
12
|
+
"mw",
|
|
13
|
+
"mh",
|
|
14
|
+
"sc",
|
|
15
|
+
"as",
|
|
16
|
+
"bc",
|
|
17
|
+
"db",
|
|
18
|
+
"iar",
|
|
19
|
+
"la",
|
|
20
|
+
"thn",
|
|
21
|
+
"vs",
|
|
22
|
+
"sc_content",
|
|
23
|
+
"sc_lang",
|
|
24
|
+
"sc_site",
|
|
25
|
+
"gray",
|
|
26
|
+
"rev",
|
|
27
|
+
"devicepixelratio",
|
|
28
|
+
"encodequality",
|
|
29
|
+
"rx",
|
|
30
|
+
"ry",
|
|
31
|
+
"rw",
|
|
32
|
+
"rh",
|
|
33
|
+
"crop",
|
|
34
|
+
];
|
|
35
|
+
function hashImageUrl(url) {
|
|
36
|
+
if (!process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET)
|
|
37
|
+
return url;
|
|
38
|
+
const uri = new URL(url.toLowerCase());
|
|
39
|
+
uri.searchParams.delete("hash");
|
|
40
|
+
const searchParams = protectedParams
|
|
41
|
+
.map((x) => ({ name: x, val: uri.searchParams.get(x) }))
|
|
42
|
+
.filter((x) => x.val)
|
|
43
|
+
.map((x) => x.name + "=" + x.val)
|
|
44
|
+
.join("&");
|
|
45
|
+
const stringToProtect = uri.pathname.substring(1) + "?" + searchParams;
|
|
46
|
+
const hash = crypto_1.default
|
|
47
|
+
.createHash("md5")
|
|
48
|
+
.update(stringToProtect + process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET, "utf16le")
|
|
49
|
+
.digest("hex");
|
|
50
|
+
uri.searchParams.set("hash", hash);
|
|
51
|
+
return uri.toString();
|
|
52
|
+
}
|
|
53
|
+
exports.hashImageUrl = hashImageUrl;
|
|
@@ -9,7 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { hashImageUrl } from "../mediaProtection";
|
|
13
14
|
// const addClassName = (otherAttrs: { [key: string]: unknown }): void => {
|
|
14
15
|
// if (otherAttrs.class) {
|
|
15
16
|
// // if any classes are defined properly already
|
|
@@ -24,62 +25,82 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
24
25
|
// }
|
|
25
26
|
// };
|
|
26
27
|
export const Picture = (_a) => {
|
|
27
|
-
var _b, _c, _d, _e;
|
|
28
|
-
var { field, imageParams, sources, defaultVariant } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant"]);
|
|
28
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
29
|
+
var { field, imageParams, sources, defaultVariant, renderJsonLinkedData } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant", "renderJsonLinkedData"]);
|
|
29
30
|
if (!field)
|
|
30
|
-
return;
|
|
31
|
-
const variants = (_b = field
|
|
32
|
-
const img = (_d = (_c = field
|
|
33
|
-
const attrs = Object.assign(
|
|
31
|
+
return null;
|
|
32
|
+
const variants = (_b = field.value) === null || _b === void 0 ? void 0 : _b.variants;
|
|
33
|
+
const img = (_d = (_c = field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
|
|
34
|
+
const attrs = Object.assign({ src: img === null || img === void 0 ? void 0 : img.src }, otherProps);
|
|
35
|
+
const video = img === null || img === void 0 ? void 0 : img.videoUrl;
|
|
36
|
+
const videoAttr = Object.assign({ src: video }, otherProps);
|
|
34
37
|
if (!(sources === null || sources === void 0 ? void 0 : sources.length)) {
|
|
35
|
-
return _jsx("img", Object.assign({}, attrs, { alt:
|
|
38
|
+
return _jsx("img", Object.assign({}, attrs, { alt: (_f = field.value) === null || _f === void 0 ? void 0 : _f.alt }));
|
|
36
39
|
}
|
|
37
40
|
else {
|
|
38
|
-
return (_jsxs("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (source.widths && source.widths.length) {
|
|
44
|
-
const getScaledImage = (variant, width) => {
|
|
45
|
-
if (width > variant.width)
|
|
46
|
-
return { src: variant.src, width: 0 };
|
|
47
|
-
else
|
|
48
|
-
return { src: variant.src + "&mw=" + width, width: width };
|
|
49
|
-
};
|
|
50
|
-
let scaledImages = source.widths.map((x) => getScaledImage(variant, x));
|
|
51
|
-
srcSet = "";
|
|
52
|
-
for (let w = 0; w < scaledImages.length; w++) {
|
|
53
|
-
if (srcSet.length)
|
|
54
|
-
srcSet = srcSet + ", ";
|
|
55
|
-
srcSet += scaledImages[w].src + " " + source.widths[w] + "w";
|
|
56
|
-
if (scaledImages[w].width === 0)
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
if (source.width) {
|
|
41
|
+
return (_jsxs(_Fragment, { children: [_jsxs("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
|
|
42
|
+
const variant = variants === null || variants === void 0 ? void 0 : variants.find((v) => v.name.toLowerCase() == source.variant.toLowerCase());
|
|
43
|
+
if (!variant)
|
|
44
|
+
return;
|
|
45
|
+
let srcSet = hashImageUrl(variant.src);
|
|
62
46
|
const getScaledImage = (variant, width) => {
|
|
63
47
|
if (width > variant.width)
|
|
64
48
|
return { src: variant.src, width: 0 };
|
|
65
49
|
else
|
|
66
|
-
return { src: variant.src +
|
|
50
|
+
return { src: variant.src + `${variant.src.includes('?') ? '&' : '?'}mw=` + width, width: width };
|
|
67
51
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
|
|
52
|
+
if (source.widths && source.widths.length) {
|
|
53
|
+
let scaledImages = source.widths.map((x) => getScaledImage(variant, x));
|
|
71
54
|
srcSet = "";
|
|
72
55
|
for (let w = 0; w < scaledImages.length; w++) {
|
|
73
56
|
if (srcSet.length)
|
|
74
57
|
srcSet = srcSet + ", ";
|
|
75
|
-
srcSet +=
|
|
58
|
+
srcSet +=
|
|
59
|
+
hashImageUrl(scaledImages[w].src) +
|
|
60
|
+
" " +
|
|
61
|
+
source.widths[w] +
|
|
62
|
+
"w";
|
|
76
63
|
if (scaledImages[w].width === 0)
|
|
77
64
|
break;
|
|
78
65
|
}
|
|
79
66
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
else {
|
|
68
|
+
if (source.width) {
|
|
69
|
+
srcSet = hashImageUrl(getScaledImage(variant, source.width).src);
|
|
70
|
+
if (source.scales) {
|
|
71
|
+
let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
|
|
72
|
+
srcSet = "";
|
|
73
|
+
for (let w = 0; w < scaledImages.length; w++) {
|
|
74
|
+
if (srcSet.length)
|
|
75
|
+
srcSet = srcSet + ", ";
|
|
76
|
+
srcSet +=
|
|
77
|
+
hashImageUrl(scaledImages[w].src) +
|
|
78
|
+
" " +
|
|
79
|
+
source.scales[w] +
|
|
80
|
+
"x";
|
|
81
|
+
if (scaledImages[w].width === 0)
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return (_jsx("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
|
|
88
|
+
}), _jsx("img", Object.assign({}, attrs, { alt: (_g = field.value) === null || _g === void 0 ? void 0 : _g.alt }))] }), renderJsonLinkedData && !video ? _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
89
|
+
__html: JSON.stringify({
|
|
90
|
+
"@context": "http://schema.org",
|
|
91
|
+
"@type": "ImageObject",
|
|
92
|
+
"image": img === null || img === void 0 ? void 0 : img.src,
|
|
93
|
+
"description": (_h = field.value) === null || _h === void 0 ? void 0 : _h.alt,
|
|
94
|
+
"name": (_j = field.value) === null || _j === void 0 ? void 0 : _j.name
|
|
95
|
+
})
|
|
96
|
+
} }) : null, video && _jsx("video", Object.assign({}, videoAttr)), renderJsonLinkedData && video ? _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
97
|
+
__html: JSON.stringify({
|
|
98
|
+
"@context": "http://schema.org",
|
|
99
|
+
"@type": "VideoObject",
|
|
100
|
+
"contentUrl": img === null || img === void 0 ? void 0 : img.src,
|
|
101
|
+
"description": (_k = field.value) === null || _k === void 0 ? void 0 : _k.alt,
|
|
102
|
+
"name": (_l = field.value) === null || _l === void 0 ? void 0 : _l.name
|
|
103
|
+
})
|
|
104
|
+
} }) : null] }));
|
|
84
105
|
}
|
|
85
106
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -27,6 +27,7 @@ const fetchRouteData = cache((path, host, mode, itemId, language) => __awaiter(v
|
|
|
27
27
|
headers: {
|
|
28
28
|
"Content-Type": "application/json",
|
|
29
29
|
Cookie: cookies().toString(),
|
|
30
|
+
"x-api-key": process.env.API_KEY,
|
|
30
31
|
},
|
|
31
32
|
next: {
|
|
32
33
|
tags: ["pages"],
|
|
@@ -61,6 +62,7 @@ const fetchRouteData = cache((path, host, mode, itemId, language) => __awaiter(v
|
|
|
61
62
|
site: data.site,
|
|
62
63
|
pageEditing: true,
|
|
63
64
|
pageState: "",
|
|
65
|
+
database: data.page.database,
|
|
64
66
|
};
|
|
65
67
|
context.fields = data.page.fields;
|
|
66
68
|
context.dictionary = yield loadDictionary(context.pageContext.site.name, context.pageContext.language, mode);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import "url";
|
|
3
|
+
const protectedParams = [
|
|
4
|
+
"w",
|
|
5
|
+
"h",
|
|
6
|
+
"mw",
|
|
7
|
+
"mh",
|
|
8
|
+
"sc",
|
|
9
|
+
"as",
|
|
10
|
+
"bc",
|
|
11
|
+
"db",
|
|
12
|
+
"iar",
|
|
13
|
+
"la",
|
|
14
|
+
"thn",
|
|
15
|
+
"vs",
|
|
16
|
+
"sc_content",
|
|
17
|
+
"sc_lang",
|
|
18
|
+
"sc_site",
|
|
19
|
+
"gray",
|
|
20
|
+
"rev",
|
|
21
|
+
"devicepixelratio",
|
|
22
|
+
"encodequality",
|
|
23
|
+
"rx",
|
|
24
|
+
"ry",
|
|
25
|
+
"rw",
|
|
26
|
+
"rh",
|
|
27
|
+
"crop",
|
|
28
|
+
];
|
|
29
|
+
export function hashImageUrl(url) {
|
|
30
|
+
if (!process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET)
|
|
31
|
+
return url;
|
|
32
|
+
const uri = new URL(url.toLowerCase());
|
|
33
|
+
uri.searchParams.delete("hash");
|
|
34
|
+
const searchParams = protectedParams
|
|
35
|
+
.map((x) => ({ name: x, val: uri.searchParams.get(x) }))
|
|
36
|
+
.filter((x) => x.val)
|
|
37
|
+
.map((x) => x.name + "=" + x.val)
|
|
38
|
+
.join("&");
|
|
39
|
+
const stringToProtect = uri.pathname.substring(1) + "?" + searchParams;
|
|
40
|
+
const hash = crypto
|
|
41
|
+
.createHash("md5")
|
|
42
|
+
.update(stringToProtect + process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET, "utf16le")
|
|
43
|
+
.digest("hex");
|
|
44
|
+
uri.searchParams.set("hash", hash);
|
|
45
|
+
return uri.toString();
|
|
46
|
+
}
|
package/package.json
CHANGED
package/types/alpacaContext.d.ts
CHANGED
package/types/fieldTypes.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface LinkField {
|
|
|
8
8
|
value: LinkValue;
|
|
9
9
|
}
|
|
10
10
|
export interface PictureValue {
|
|
11
|
-
|
|
11
|
+
name: string;
|
|
12
12
|
alt: string;
|
|
13
13
|
variants: PictureVariant[];
|
|
14
14
|
loopVideos: boolean;
|
|
@@ -16,7 +16,7 @@ export interface PictureValue {
|
|
|
16
16
|
export interface PictureVariant {
|
|
17
17
|
name: string;
|
|
18
18
|
src: string;
|
|
19
|
-
|
|
19
|
+
videoUrl: string;
|
|
20
20
|
width: number;
|
|
21
21
|
}
|
|
22
22
|
export interface ImageField {
|
|
@@ -48,3 +48,15 @@ export interface EnhancedTreeListFieldItem {
|
|
|
48
48
|
export type EnhancedTreeListField = {
|
|
49
49
|
value: EnhancedTreeListFieldItem[];
|
|
50
50
|
};
|
|
51
|
+
export type CheckboxField = {
|
|
52
|
+
value: boolean;
|
|
53
|
+
};
|
|
54
|
+
export type DateField = {
|
|
55
|
+
value: DateFieldValue;
|
|
56
|
+
};
|
|
57
|
+
export type DateFieldValue = {
|
|
58
|
+
date: string;
|
|
59
|
+
};
|
|
60
|
+
export type NumberField = {
|
|
61
|
+
value: number;
|
|
62
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type SitecoreItem = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
key: string;
|
|
5
|
+
template: Template;
|
|
6
|
+
fields: Field[];
|
|
7
|
+
children: SitecoreItem[];
|
|
8
|
+
parentId: string;
|
|
9
|
+
url: string;
|
|
10
|
+
versionsCount: number;
|
|
11
|
+
};
|
|
12
|
+
export type Template = {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
export type Field = {
|
|
17
|
+
name: string;
|
|
18
|
+
value: string;
|
|
19
|
+
jsonValue: Value;
|
|
20
|
+
targetItems: SitecoreItem[];
|
|
21
|
+
};
|
|
22
|
+
export type Value = {
|
|
23
|
+
value: any;
|
|
24
|
+
};
|
package/types/index.d.ts
CHANGED
package/types/loadRouteData.d.ts
CHANGED
|
@@ -12,6 +12,15 @@ export type Page = Response & {
|
|
|
12
12
|
placeholders: PlaceholderData[];
|
|
13
13
|
meta: {
|
|
14
14
|
title: string;
|
|
15
|
+
description: string;
|
|
16
|
+
canonical: string;
|
|
17
|
+
keywords: string;
|
|
18
|
+
hrefLangTags: object;
|
|
19
|
+
"og:title": string;
|
|
20
|
+
"og:description": string;
|
|
21
|
+
"og:url": string;
|
|
22
|
+
"og:type": string;
|
|
23
|
+
"og:image": string;
|
|
15
24
|
};
|
|
16
25
|
};
|
|
17
26
|
export type Redirect = Response & {
|