@adobe/helix-html-pipeline 5.4.0 → 5.4.2
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 +4 -4
- package/src/html-pipe.js +35 -5
- package/src/steps/render.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [5.4.2](https://github.com/adobe/helix-html-pipeline/compare/v5.4.1...v5.4.2) (2023-12-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* handle redirects correctly for static .html ([#476](https://github.com/adobe/helix-html-pipeline/issues/476)) ([5fd99d7](https://github.com/adobe/helix-html-pipeline/commit/5fd99d798076ba6d693fbf70a24ce5d1290fc9de))
|
|
7
|
+
|
|
8
|
+
## [5.4.1](https://github.com/adobe/helix-html-pipeline/compare/v5.4.0...v5.4.1) (2023-12-19)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* do not include empty canonical ([#273](https://github.com/adobe/helix-html-pipeline/issues/273)) ([66e5d9c](https://github.com/adobe/helix-html-pipeline/commit/66e5d9c1e42ac5844bbd20ec68d7cb31b30d83af))
|
|
14
|
+
|
|
1
15
|
# [5.4.0](https://github.com/adobe/helix-html-pipeline/compare/v5.3.0...v5.4.0) (2023-12-15)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.2",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
"@semantic-release/git": "10.0.1",
|
|
77
77
|
"@semantic-release/npm": "11.0.2",
|
|
78
78
|
"c8": "8.0.1",
|
|
79
|
-
"eslint": "8.
|
|
79
|
+
"eslint": "8.56.0",
|
|
80
80
|
"eslint-import-resolver-exports": "1.0.0-beta.5",
|
|
81
81
|
"eslint-plugin-header": "3.1.1",
|
|
82
|
-
"eslint-plugin-import": "2.29.
|
|
82
|
+
"eslint-plugin-import": "2.29.1",
|
|
83
83
|
"esmock": "2.6.0",
|
|
84
84
|
"husky": "8.0.3",
|
|
85
85
|
"js-yaml": "4.1.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"mocha": "10.2.0",
|
|
90
90
|
"mocha-multi-reporters": "1.5.1",
|
|
91
91
|
"mocha-suppress-logs": "0.4.1",
|
|
92
|
-
"semantic-release": "22.0.
|
|
92
|
+
"semantic-release": "22.0.12"
|
|
93
93
|
},
|
|
94
94
|
"lint-staged": {
|
|
95
95
|
"*.js": "eslint",
|
package/src/html-pipe.js
CHANGED
|
@@ -54,6 +54,31 @@ async function fetchContentWith404Fallback(state, req, res) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Loads the resource from the content bus but only handles the redirect; otherwise applies
|
|
59
|
+
* a 404 fallback.
|
|
60
|
+
* @param state
|
|
61
|
+
* @param req
|
|
62
|
+
* @param res
|
|
63
|
+
* @returns {Promise<void>}
|
|
64
|
+
*/
|
|
65
|
+
async function fetchContentRedirectWith404Fallback(state, req, res) {
|
|
66
|
+
// force load from content bus again
|
|
67
|
+
state.content.sourceBus = 'content';
|
|
68
|
+
const prevError = res.error;
|
|
69
|
+
try {
|
|
70
|
+
await fetchContent(state, req, res);
|
|
71
|
+
} finally {
|
|
72
|
+
state.content.sourceBus = 'code';
|
|
73
|
+
}
|
|
74
|
+
if (res.status !== 301) {
|
|
75
|
+
// force 404
|
|
76
|
+
res.status = 404;
|
|
77
|
+
res.error = prevError;
|
|
78
|
+
await fetch404(state, req, res);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
57
82
|
/**
|
|
58
83
|
* Runs the default pipeline and returns the response.
|
|
59
84
|
* @param {PipelineState} state
|
|
@@ -104,13 +129,18 @@ export async function htmlPipe(state, req) {
|
|
|
104
129
|
// ...and apply the folder mapping
|
|
105
130
|
state.timer?.update('content-fetch');
|
|
106
131
|
let contentPromise = await fetchContent(state, req, res);
|
|
107
|
-
// ...but only if the current resource doesn't exist
|
|
108
132
|
if (res.status === 404) {
|
|
109
|
-
|
|
110
|
-
if (state.
|
|
111
|
-
contentPromise =
|
|
133
|
+
// special handling for code-bus 404
|
|
134
|
+
if (state.content.sourceBus === 'code') {
|
|
135
|
+
contentPromise = fetchContentRedirectWith404Fallback(state, req, res);
|
|
112
136
|
} else {
|
|
113
|
-
|
|
137
|
+
// ...apply folder mapping if the current resource doesn't exist
|
|
138
|
+
await folderMapping(state);
|
|
139
|
+
if (state.info.unmappedPath) {
|
|
140
|
+
contentPromise = fetchContentWith404Fallback(state, req, res);
|
|
141
|
+
} else {
|
|
142
|
+
contentPromise = fetch404(state, req, res);
|
|
143
|
+
}
|
|
114
144
|
}
|
|
115
145
|
}
|
|
116
146
|
|
package/src/steps/render.js
CHANGED
|
@@ -55,7 +55,9 @@ export default async function render(state, req, res) {
|
|
|
55
55
|
$head.children.push(h('title', meta.title));
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
if (meta.canonical) {
|
|
59
|
+
appendElement($head, createElement('link', 'rel', 'canonical', 'href', meta.canonical));
|
|
60
|
+
}
|
|
59
61
|
|
|
60
62
|
for (const [name, value] of Object.entries(meta.page)) {
|
|
61
63
|
const attr = name.includes(':') && !name.startsWith('twitter:') ? 'property' : 'name';
|