@adobe/helix-html-pipeline 6.12.9 → 6.13.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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [6.13.0](https://github.com/adobe/helix-html-pipeline/compare/v6.12.10...v6.13.0) (2024-07-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* include json-ld from metadata ([f1c9f3f](https://github.com/adobe/helix-html-pipeline/commit/f1c9f3f5b1980dec8dc257c4f1f36f75fb0a0a69)), closes [#648](https://github.com/adobe/helix-html-pipeline/issues/648)
|
|
7
|
+
|
|
8
|
+
## [6.12.10](https://github.com/adobe/helix-html-pipeline/compare/v6.12.9...v6.12.10) (2024-07-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update dependency @adobe/helix-markdown-support to v7.1.4 ([8a27bce](https://github.com/adobe/helix-html-pipeline/commit/8a27bce15ffe5264f5fa057aeaa3e08a588de05f))
|
|
14
|
+
|
|
1
15
|
## [6.12.9](https://github.com/adobe/helix-html-pipeline/compare/v6.12.8...v6.12.9) (2024-07-06)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.13.0",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"node": ">=16.x"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@adobe/helix-markdown-support": "7.1.
|
|
46
|
+
"@adobe/helix-markdown-support": "7.1.4",
|
|
47
47
|
"@adobe/helix-shared-utils": "3.0.2",
|
|
48
48
|
"@adobe/mdast-util-gridtables": "4.0.6",
|
|
49
49
|
"@adobe/remark-gridtables": "3.0.6",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"eslint-import-resolver-exports": "1.0.0-beta.5",
|
|
81
81
|
"eslint-plugin-header": "3.1.1",
|
|
82
82
|
"eslint-plugin-import": "2.29.1",
|
|
83
|
-
"esmock": "2.6.
|
|
84
|
-
"husky": "9.
|
|
83
|
+
"esmock": "2.6.7",
|
|
84
|
+
"husky": "9.1.3",
|
|
85
85
|
"js-yaml": "4.1.0",
|
|
86
|
-
"jsdom": "24.1.
|
|
87
|
-
"junit-report-builder": "
|
|
86
|
+
"jsdom": "24.1.1",
|
|
87
|
+
"junit-report-builder": "4.0.0",
|
|
88
88
|
"lint-staged": "15.2.7",
|
|
89
|
-
"mocha": "10.
|
|
89
|
+
"mocha": "10.7.0",
|
|
90
90
|
"mocha-multi-reporters": "1.5.1",
|
|
91
91
|
"mocha-suppress-logs": "0.5.1",
|
|
92
92
|
"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.config?.head?.html;
|
|
76
103
|
if (headHtml) {
|