@adobe/helix-html-pipeline 5.11.12 → 5.12.0
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/CHANGELOG.md +14 -0
- package/package.json +7 -7
- package/src/steps/render.js +27 -0
- package/src/steps/utils.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [5.12.0](https://github.com/adobe/helix-html-pipeline/compare/v5.11.13...v5.12.0) (2024-07-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* include json-ld from metadata ([#657](https://github.com/adobe/helix-html-pipeline/issues/657)) ([56c7d37](https://github.com/adobe/helix-html-pipeline/commit/56c7d376014583e8d6664886902ebc2400874bb2)), closes [#648](https://github.com/adobe/helix-html-pipeline/issues/648)
|
|
7
|
+
|
|
8
|
+
## [5.11.13](https://github.com/adobe/helix-html-pipeline/compare/v5.11.12...v5.11.13) (2024-07-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* .aem.* URLs should both be rewritten to keep existing content compatible ([b6b5b04](https://github.com/adobe/helix-html-pipeline/commit/b6b5b04d7d461471173bf33ac801e3b0f54e1a3c)), closes [#498](https://github.com/adobe/helix-html-pipeline/issues/498)
|
|
14
|
+
|
|
1
15
|
## [5.11.12](https://github.com/adobe/helix-html-pipeline/compare/v5.11.11...v5.11.12) (2024-07-07)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"lint": "eslint .",
|
|
18
18
|
"semantic-release": "semantic-release",
|
|
19
19
|
"semantic-release-dry": "semantic-release --dry-run",
|
|
20
|
-
"prepare": "husky
|
|
20
|
+
"prepare": "husky"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
"eslint-import-resolver-exports": "1.0.0-beta.5",
|
|
83
83
|
"eslint-plugin-header": "3.1.1",
|
|
84
84
|
"eslint-plugin-import": "2.29.1",
|
|
85
|
-
"esmock": "2.6.
|
|
86
|
-
"husky": "9.
|
|
85
|
+
"esmock": "2.6.7",
|
|
86
|
+
"husky": "9.1.3",
|
|
87
87
|
"js-yaml": "4.1.0",
|
|
88
|
-
"jsdom": "24.1.
|
|
89
|
-
"junit-report-builder": "
|
|
88
|
+
"jsdom": "24.1.1",
|
|
89
|
+
"junit-report-builder": "4.0.0",
|
|
90
90
|
"lint-staged": "15.2.7",
|
|
91
|
-
"mocha": "10.
|
|
91
|
+
"mocha": "10.7.0",
|
|
92
92
|
"mocha-multi-reporters": "1.5.1",
|
|
93
93
|
"mocha-suppress-logs": "0.5.1",
|
|
94
94
|
"semantic-release": "24.0.0"
|
package/src/steps/render.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { h } from 'hastscript';
|
|
15
15
|
import { unified } from 'unified';
|
|
16
16
|
import rehypeParse from 'rehype-parse';
|
|
17
|
+
import { cleanupHeaderValue } from '@adobe/helix-shared-utils';
|
|
17
18
|
|
|
18
19
|
function appendElement($parent, $el) {
|
|
19
20
|
if ($el) {
|
|
@@ -34,6 +35,13 @@ function createElement(name, ...attrs) {
|
|
|
34
35
|
return h(name, properties);
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
function sanitizeJsonLd(jsonLd) {
|
|
39
|
+
if (jsonLd.toLowerCase().indexOf('</script>') >= 0) {
|
|
40
|
+
throw new Error('script tag not allowed');
|
|
41
|
+
}
|
|
42
|
+
return JSON.stringify(JSON.parse(jsonLd.trim()));
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
/**
|
|
38
46
|
* @type PipelineStep
|
|
39
47
|
* @param {PipelineState} state
|
|
@@ -59,7 +67,13 @@ export default async function render(state, req, res) {
|
|
|
59
67
|
appendElement($head, createElement('link', 'rel', 'canonical', 'href', meta.canonical));
|
|
60
68
|
}
|
|
61
69
|
|
|
70
|
+
let jsonLd;
|
|
62
71
|
for (const [name, value] of Object.entries(meta.page)) {
|
|
72
|
+
if (name.toLowerCase() === 'json-ld') {
|
|
73
|
+
jsonLd = value;
|
|
74
|
+
// eslint-disable-next-line no-continue
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
63
77
|
const attr = name.includes(':') && !name.startsWith('twitter:') ? 'property' : 'name';
|
|
64
78
|
if (Array.isArray(value)) {
|
|
65
79
|
for (const v of value) {
|
|
@@ -71,6 +85,19 @@ export default async function render(state, req, res) {
|
|
|
71
85
|
}
|
|
72
86
|
appendElement($head, createElement('link', 'rel', 'alternate', 'type', 'application/xml+atom', 'href', meta.feed, 'title', `${meta.title} feed`));
|
|
73
87
|
|
|
88
|
+
// inject json ld if valid
|
|
89
|
+
if (jsonLd) {
|
|
90
|
+
const props = { type: 'application/ld+json' };
|
|
91
|
+
try {
|
|
92
|
+
jsonLd = sanitizeJsonLd(jsonLd);
|
|
93
|
+
} catch (e) {
|
|
94
|
+
jsonLd = '';
|
|
95
|
+
props['data-error'] = `error in json-ld: ${cleanupHeaderValue(e.message)}`;
|
|
96
|
+
}
|
|
97
|
+
const script = h('script', props, jsonLd);
|
|
98
|
+
$head.children.push(script);
|
|
99
|
+
}
|
|
100
|
+
|
|
74
101
|
// inject head.html
|
|
75
102
|
const headHtml = state.helixConfig?.head?.data.html;
|
|
76
103
|
if (headHtml) {
|
package/src/steps/utils.js
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
const AZURE_BLOB_REGEXP = /^https:\/\/hlx\.blob\.core\.windows\.net\/external\//;
|
|
14
14
|
|
|
15
|
-
const MEDIA_BLOB_REGEXP = /^https:\/\/.*\.hlx3
|
|
15
|
+
const MEDIA_BLOB_REGEXP = /^https:\/\/.*\.(aem|hlx3?)\.(live|page)\/media_.*/;
|
|
16
16
|
|
|
17
|
-
const HELIX_URL_REGEXP = /^https:\/\/(?!admin\.|www\.)[^.]+\.hlx3
|
|
17
|
+
const HELIX_URL_REGEXP = /^https:\/\/(?!admin\.|www\.)[^.]+\.(aem|hlx3?)\.(live|page)\/?.*/;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Returns the original host name from the request to the outer CDN.
|