@adobe/helix-html-pipeline 6.29.12 → 6.30.1

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,17 @@
1
+ ## [6.30.1](https://github.com/adobe/helix-html-pipeline/compare/v6.30.0...v6.30.1) (2026-08-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **sitemap-index:** static version in code, dynamic version in content ([#1125](https://github.com/adobe/helix-html-pipeline/issues/1125)) ([5c76a06](https://github.com/adobe/helix-html-pipeline/commit/5c76a060b3ff5a1c198c565f256b3ee7a5bbbc0b))
7
+
8
+ # [6.30.0](https://github.com/adobe/helix-html-pipeline/compare/v6.29.12...v6.30.0) (2026-08-14)
9
+
10
+
11
+ ### Features
12
+
13
+ * add support for sitemap index generation ([#1124](https://github.com/adobe/helix-html-pipeline/issues/1124)) ([f5bc462](https://github.com/adobe/helix-html-pipeline/commit/f5bc4624ac53df576bcdc22ea8e29359e36ed620))
14
+
1
15
  ## [6.29.12](https://github.com/adobe/helix-html-pipeline/compare/v6.29.11...v6.29.12) (2026-08-12)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "6.29.12",
3
+ "version": "6.30.1",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/index.js CHANGED
@@ -14,6 +14,7 @@ export * from './json-pipe.js';
14
14
  export * from './options-pipe.js';
15
15
  export * from './robots-pipe.js';
16
16
  export * from './sitemap-pipe.js';
17
+ export * from './sitemap-index-pipe.js';
17
18
  export * from './PipelineContent.js';
18
19
  export * from './PipelineRequest.js';
19
20
  export * from './PipelineResponse.js';
@@ -0,0 +1,117 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import escape from 'lodash.escape';
13
+ import { cleanupHeaderValue } from '@adobe/helix-shared-utils';
14
+ import fetchContent from './steps/fetch-content.js';
15
+ import renderCode from './steps/render-code.js';
16
+ import setXSurrogateKeyHeader from './steps/set-x-surrogate-key-header.js';
17
+ import setCustomResponseHeaders from './steps/set-custom-response-headers.js';
18
+ import { PipelineStatusError } from './PipelineStatusError.js';
19
+ import { PipelineResponse } from './PipelineResponse.js';
20
+ import initConfig from './steps/init-config.js';
21
+ import { extractLastModified, recordLastModified, setLastModified } from './utils/last-modified.js';
22
+
23
+ async function generateSitemapIndex(state) {
24
+ const {
25
+ owner, repo, ref, partition,
26
+ previewHost, liveHost, prodHost, config,
27
+ } = state;
28
+
29
+ const { sitemap } = config;
30
+ if (!sitemap?.index) {
31
+ throw new PipelineStatusError(404, 'No sitemap index defined in configuration');
32
+ }
33
+ const host = partition === 'preview'
34
+ ? (previewHost || `${ref}--${repo}--${owner}.aem.page`)
35
+ : (prodHost || liveHost || `${ref}--${repo}--${owner}.aem.live`);
36
+ const loc = (path) => (path.startsWith('/') ? `https://${host}${escape(path)}` : path);
37
+ const xml = [
38
+ '<?xml version="1.0" encoding="utf-8"?>',
39
+ '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
40
+ ...sitemap.index.map((index) => ` <sitemap>
41
+ <loc>${loc(index)}</loc>
42
+ </sitemap>`),
43
+ '</sitemapindex>',
44
+ '',
45
+ ].join('\n');
46
+ return new PipelineResponse(xml, {
47
+ status: 200,
48
+ headers: {
49
+ 'content-type': 'application/xml; charset=utf-8',
50
+ 'last-modified': sitemap.lastModified,
51
+ },
52
+ });
53
+ }
54
+
55
+ export async function sitemapIndexPipe(state, req) {
56
+ const { log } = state;
57
+ state.type = 'sitemap-index';
58
+
59
+ if (state.info?.path !== '/sitemap-index.xml') {
60
+ // this should not happen as it would mean that the caller used the wrong route. so we respond
61
+ // with a 500 to indicate that something is wrong.
62
+ return new PipelineResponse('', {
63
+ status: 500,
64
+ headers: {
65
+ 'x-error': 'invalid route',
66
+ },
67
+ });
68
+ }
69
+
70
+ /** @type PipelineResponse */
71
+ const res = new PipelineResponse('', {
72
+ headers: {
73
+ 'content-type': 'text/plain; charset=utf-8',
74
+ },
75
+ });
76
+
77
+ try {
78
+ await initConfig(state, req, res);
79
+
80
+ // fetch sitemap-index.xml
81
+ state.timer?.update('content-fetch');
82
+ state.content.sourceBus = 'code';
83
+ await fetchContent(state, req, res);
84
+ if (res.status === 404) {
85
+ state.content.sourceBus = 'content';
86
+ const ret = await generateSitemapIndex(state);
87
+ if (ret.status === 200) {
88
+ res.status = 200;
89
+ recordLastModified(state, res, 'content', extractLastModified(ret.headers));
90
+ delete res.error;
91
+ state.content.data = ret.body;
92
+ }
93
+ }
94
+ if (res.error) {
95
+ // if content loading produced an error, we're done.
96
+ throw new PipelineStatusError(res.status, res.error);
97
+ }
98
+
99
+ state.timer?.update('serialize');
100
+ await renderCode(state, req, res);
101
+ setLastModified(state, res);
102
+ await setCustomResponseHeaders(state, req, res);
103
+ await setXSurrogateKeyHeader(state, req, res);
104
+ } catch (e) {
105
+ res.error = e.message;
106
+ res.status = e.code || 500;
107
+
108
+ const level = res.status >= 500 ? 'error' : 'info';
109
+ log[level](`pipeline status: ${res.status} ${res.error}`);
110
+ res.headers.set('x-error', cleanupHeaderValue(res.error));
111
+ if (res.status < 500) {
112
+ await setCustomResponseHeaders(state, req, res);
113
+ await setXSurrogateKeyHeader(state, req, res);
114
+ }
115
+ }
116
+ return res;
117
+ }
@@ -57,9 +57,11 @@ export async function computeCodePathKey(state) {
57
57
  export default async function setXSurrogateKeyHeader(state, req, res) {
58
58
  const {
59
59
  contentBusId, owner, repo, ref, partition,
60
+ info: { path },
60
61
  } = state;
61
62
 
62
63
  const isCode = state.content.sourceBus === 'code';
64
+ const purgeMetadataAndHead = !['/sitemap.xml', '/sitemap-index.xml'].includes(path);
63
65
 
64
66
  // provide either (prefixed) preview or (unprefixed) live content keys
65
67
  const contentKeyPrefix = partition === 'preview' ? 'p_' : '';
@@ -70,8 +72,10 @@ export default async function setXSurrogateKeyHeader(state, req, res) {
70
72
  keys.push(`${ref}--${repo}--${owner}_code`);
71
73
  } else {
72
74
  keys.push(`${contentKeyPrefix}${hash}`);
73
- keys.push(`${contentKeyPrefix}${contentBusId}_metadata`);
74
- keys.push(`${ref}--${repo}--${owner}_head`);
75
+ if (purgeMetadataAndHead) {
76
+ keys.push(`${contentKeyPrefix}${contentBusId}_metadata`);
77
+ keys.push(`${ref}--${repo}--${owner}_head`);
78
+ }
75
79
  keys.push(`${contentKeyPrefix}${contentBusId}`);
76
80
  }
77
81
  // for folder-mapped resources, we also need to include the surrogate key of the mapped metadata