@adobe/helix-html-pipeline 3.11.8 → 3.11.10
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
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [3.11.10](https://github.com/adobe/helix-html-pipeline/compare/v3.11.9...v3.11.10) (2023-06-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* coverage ([#326](https://github.com/adobe/helix-html-pipeline/issues/326)) ([31a34b9](https://github.com/adobe/helix-html-pipeline/commit/31a34b96a5ed01c002e9951507712904f8ff5615))
|
|
7
|
+
* output image title attribute ([3893776](https://github.com/adobe/helix-html-pipeline/commit/3893776a5b6ce786e69e9475dc148955a634d719)), closes [#308](https://github.com/adobe/helix-html-pipeline/issues/308)
|
|
8
|
+
|
|
9
|
+
## [3.11.9](https://github.com/adobe/helix-html-pipeline/compare/v3.11.8...v3.11.9) (2023-05-25)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* properly set surrogate keys for 404 with .plain.html ([#321](https://github.com/adobe/helix-html-pipeline/issues/321)) ([c7a956a](https://github.com/adobe/helix-html-pipeline/commit/c7a956a1684e758b5c0cf343c68a8dba1f8bc226)), closes [#320](https://github.com/adobe/helix-html-pipeline/issues/320)
|
|
15
|
+
|
|
1
16
|
## [3.11.8](https://github.com/adobe/helix-html-pipeline/compare/v3.11.7...v3.11.8) (2023-05-22)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-html-pipeline",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.10",
|
|
4
4
|
"description": "Helix HTML Pipeline",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"esmock": "2.2.3",
|
|
91
91
|
"husky": "8.0.3",
|
|
92
92
|
"js-yaml": "4.1.0",
|
|
93
|
-
"jsdom": "22.
|
|
93
|
+
"jsdom": "22.1.0",
|
|
94
94
|
"junit-report-builder": "3.0.1",
|
|
95
95
|
"lint-staged": "13.2.2",
|
|
96
96
|
"mocha": "10.2.0",
|
|
@@ -18,7 +18,7 @@ const BREAK_POINTS = [
|
|
|
18
18
|
{ width: '750' },
|
|
19
19
|
];
|
|
20
20
|
|
|
21
|
-
export function createOptimizedPicture(src, alt = '') {
|
|
21
|
+
export function createOptimizedPicture(src, alt = '', title = undefined) {
|
|
22
22
|
const url = new URL(src, 'https://localhost/');
|
|
23
23
|
const { pathname, hash = '' } = url;
|
|
24
24
|
const props = new URLSearchParams(hash.substring(1));
|
|
@@ -55,6 +55,7 @@ export function createOptimizedPicture(src, alt = '') {
|
|
|
55
55
|
return h('img', {
|
|
56
56
|
loading: 'lazy',
|
|
57
57
|
alt,
|
|
58
|
+
'data-title': title === alt ? undefined : title,
|
|
58
59
|
type: v.type,
|
|
59
60
|
src: srcset,
|
|
60
61
|
width,
|
|
@@ -78,8 +79,8 @@ export default async function createPictures({ content }) {
|
|
|
78
79
|
const { hast } = content;
|
|
79
80
|
|
|
80
81
|
visitParents(hast, isMediaImage, (img, parents) => {
|
|
81
|
-
const { src, alt } = img.properties;
|
|
82
|
-
const picture = createOptimizedPicture(src, alt);
|
|
82
|
+
const { src, alt, title } = img.properties;
|
|
83
|
+
const picture = createOptimizedPicture(src, alt, title);
|
|
83
84
|
|
|
84
85
|
// check if parent has style and unwrap if needed
|
|
85
86
|
const parent = parents[parents.length - 1];
|
package/src/steps/fetch-404.js
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import { computeSurrogateKey } from '@adobe/helix-shared-utils';
|
|
13
12
|
import { extractLastModified } from '../utils/last-modified.js';
|
|
13
|
+
import { getPathKey } from './set-x-surrogate-key-header.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Loads the 404.html from code-bus and stores it in `res.body`
|
|
@@ -21,9 +21,7 @@ import { extractLastModified } from '../utils/last-modified.js';
|
|
|
21
21
|
* @returns {Promise<void>}
|
|
22
22
|
*/
|
|
23
23
|
export default async function fetch404(state, req, res) {
|
|
24
|
-
const {
|
|
25
|
-
contentBusId, info, owner, repo, ref,
|
|
26
|
-
} = state;
|
|
24
|
+
const { owner, repo, ref } = state;
|
|
27
25
|
const ret = await state.s3Loader.getObject('helix-code-bus', `${owner}/${repo}/${ref}/404.html`);
|
|
28
26
|
if (ret.status === 200) {
|
|
29
27
|
// override last-modified if source-last-modified is set
|
|
@@ -36,7 +34,9 @@ export default async function fetch404(state, req, res) {
|
|
|
36
34
|
res.body = ret.body;
|
|
37
35
|
res.headers.set('last-modified', ret.headers.get('last-modified'));
|
|
38
36
|
res.headers.set('content-type', 'text/html; charset=utf-8');
|
|
39
|
-
const pathKey = await computeSurrogateKey(`${contentBusId}${info.path}`);
|
|
40
|
-
res.headers.set('x-surrogate-key', `${pathKey} ${ref}--${repo}--${owner}_404`);
|
|
41
37
|
}
|
|
38
|
+
|
|
39
|
+
// set 404 keys in any case
|
|
40
|
+
const pathKey = await getPathKey(state);
|
|
41
|
+
res.headers.set('x-surrogate-key', `${pathKey} ${ref}--${repo}--${owner}_404`);
|
|
42
42
|
}
|
|
@@ -11,6 +11,24 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { computeSurrogateKey } from '@adobe/helix-shared-utils';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Returns the surrogate key based on the contentBusId and the resource path
|
|
16
|
+
* @param state
|
|
17
|
+
* @returns {Promise<string>}
|
|
18
|
+
*/
|
|
19
|
+
export async function getPathKey(state) {
|
|
20
|
+
const { contentBusId, info } = state;
|
|
21
|
+
let { path } = info;
|
|
22
|
+
// surrogate key for path
|
|
23
|
+
// strip [index].plain.html
|
|
24
|
+
if (path.endsWith('index.plain.html')) {
|
|
25
|
+
path = path.substring(0, path.length - 'index.plain.html'.length);
|
|
26
|
+
} else if (path.endsWith('.plain.html')) {
|
|
27
|
+
path = path.substring(0, path.length - '.plain.html'.length);
|
|
28
|
+
}
|
|
29
|
+
return computeSurrogateKey(`${contentBusId}${path}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
14
32
|
/**
|
|
15
33
|
* @type PipelineStep
|
|
16
34
|
* @param {PipelineState} state
|
|
@@ -20,26 +38,16 @@ import { computeSurrogateKey } from '@adobe/helix-shared-utils';
|
|
|
20
38
|
*/
|
|
21
39
|
export default async function setXSurrogateKeyHeader(state, req, res) {
|
|
22
40
|
const {
|
|
23
|
-
content, contentBusId, owner, repo, ref,
|
|
41
|
+
content, contentBusId, owner, repo, ref,
|
|
24
42
|
} = state;
|
|
25
43
|
|
|
26
|
-
let { path } = info;
|
|
27
|
-
|
|
28
44
|
const keys = [];
|
|
29
45
|
if (content.sourceLocation) {
|
|
30
46
|
keys.push(await computeSurrogateKey(content.sourceLocation));
|
|
31
47
|
}
|
|
32
48
|
|
|
33
|
-
|
|
34
|
-
// strip [index].plain.html
|
|
35
|
-
if (path.endsWith('index.plain.html')) {
|
|
36
|
-
path = path.substring(0, path.length - 'index.plain.html'.length);
|
|
37
|
-
} else if (path.endsWith('.plain.html')) {
|
|
38
|
-
path = path.substring(0, path.length - '.plain.html'.length);
|
|
39
|
-
}
|
|
40
|
-
const hash = await computeSurrogateKey(`${contentBusId}${path}`);
|
|
49
|
+
const hash = await getPathKey(state);
|
|
41
50
|
keys.push(hash);
|
|
42
|
-
|
|
43
51
|
keys.push(`${contentBusId}_metadata`);
|
|
44
52
|
keys.push(`${ref}--${repo}--${owner}_head`);
|
|
45
53
|
|