@adobe/helix-html-pipeline 6.4.0 → 6.5.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 CHANGED
@@ -1,3 +1,22 @@
1
+ # [6.5.0](https://github.com/adobe/helix-html-pipeline/compare/v6.4.1...v6.5.0) (2024-02-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * allow static html with selectors ([#510](https://github.com/adobe/helix-html-pipeline/issues/510)) ([91e20a1](https://github.com/adobe/helix-html-pipeline/commit/91e20a19ec4bfbdbfe80b6ee78b256a7ebc208d1)), closes [#481](https://github.com/adobe/helix-html-pipeline/issues/481)
7
+
8
+
9
+ ### Features
10
+
11
+ * remove source-location surrogate key ([049caf0](https://github.com/adobe/helix-html-pipeline/commit/049caf059530ca11025a3f4b6c9ca50db0e13122))
12
+
13
+ ## [6.4.1](https://github.com/adobe/helix-html-pipeline/compare/v6.4.0...v6.4.1) (2024-02-08)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * use correct partition ([#534](https://github.com/adobe/helix-html-pipeline/issues/534)) ([960256e](https://github.com/adobe/helix-html-pipeline/commit/960256eb6dd4045775ccf3203aa6b324558909d0))
19
+
1
20
  # [6.4.0](https://github.com/adobe/helix-html-pipeline/compare/v6.3.4...v6.4.0) (2024-02-06)
2
21
 
3
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "6.4.0",
3
+ "version": "6.5.0",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -11,7 +11,6 @@
11
11
  */
12
12
  import escape from 'lodash.escape';
13
13
  import { cleanupHeaderValue } from '@adobe/helix-shared-utils';
14
- import { authenticate } from './steps/authenticate.js';
15
14
  import fetchContent from './steps/fetch-content.js';
16
15
  import renderCode from './steps/render-code.js';
17
16
  import setXSurrogateKeyHeader from './steps/set-x-surrogate-key-header.js';
@@ -21,9 +20,9 @@ import { PipelineResponse } from './PipelineResponse.js';
21
20
  import initConfig from './steps/init-config.js';
22
21
  import { extractLastModified, updateLastModified } from './utils/last-modified.js';
23
22
 
24
- async function generateSitemap(state, partition) {
23
+ async function generateSitemap(state) {
25
24
  const {
26
- owner, repo, ref, contentBusId, s3Loader, log,
25
+ owner, repo, ref, contentBusId, s3Loader, log, partition,
27
26
  previewHost, liveHost, prodHost,
28
27
  } = state;
29
28
  const ret = await s3Loader.getObject('helix-content-bus', `${contentBusId}/live/sitemap.json`);
@@ -75,12 +74,9 @@ async function generateSitemap(state, partition) {
75
74
  * @returns {PipelineResponse}
76
75
  */
77
76
  export async function sitemapPipe(state, req) {
78
- const { partition, log } = state;
77
+ const { log } = state;
79
78
  state.type = 'sitemap';
80
79
 
81
- // force loading from preview
82
- state.partition = 'preview';
83
-
84
80
  if (state.info?.path !== '/sitemap.xml') {
85
81
  // this should not happen as it would mean that the caller used the wrong route. so we respond
86
82
  // with a 500 to indicate that something is wrong.
@@ -102,18 +98,11 @@ export async function sitemapPipe(state, req) {
102
98
  try {
103
99
  await initConfig(state, req, res);
104
100
 
105
- // await requireProject(state, req, res);
106
- if (res.error !== 401) {
107
- await authenticate(state, req, res);
108
- }
109
-
110
- // ...and apply the folder mapping
111
- state.timer?.update('content-fetch');
112
-
113
101
  // fetch sitemap.xml
102
+ state.timer?.update('content-fetch');
114
103
  await fetchContent(state, req, res);
115
104
  if (res.status === 404) {
116
- const ret = await generateSitemap(state, partition);
105
+ const ret = await generateSitemap(state);
117
106
  if (ret.status === 200) {
118
107
  res.status = 200;
119
108
  updateLastModified(state, res, extractLastModified(ret.headers));
@@ -42,19 +42,16 @@ export async function getPathKey(state) {
42
42
  */
43
43
  export default async function setXSurrogateKeyHeader(state, req, res) {
44
44
  const {
45
- content, contentBusId, owner, repo, ref,
45
+ contentBusId, owner, repo, ref,
46
46
  } = state;
47
-
48
- const keys = [];
49
- if (content.sourceLocation) {
50
- keys.push(await computeSurrogateKey(content.sourceLocation));
51
- }
52
-
53
47
  const hash = await getPathKey(state);
54
- keys.push(hash);
55
- keys.push(`${contentBusId}_metadata`);
56
- keys.push(`${ref}--${repo}--${owner}_head`);
48
+ const keys = [
49
+ hash,
50
+ `${contentBusId}_metadata`,
51
+ `${ref}--${repo}--${owner}_head`,
52
+ ];
57
53
 
54
+ // for folder-mapped resources, we also need to include the surrogate key of the mapped metadata
58
55
  if (state.mapped) {
59
56
  keys.push(`${hash}_metadata`);
60
57
  }
package/src/utils/path.js CHANGED
@@ -67,15 +67,18 @@ export function getPathInfo(path) {
67
67
  }
68
68
  let resExt = info.extension;
69
69
  if (info.selector) {
70
- if (resExt === '.html') {
71
- // force .plain.html as markdown resources
70
+ if (info.selector === 'plain' && resExt === '.html') {
71
+ // force .plain.html as markdown resources and remove selector from path
72
72
  resExt = '.md';
73
+ fileName = `${baseName}${resExt}`;
74
+ } else {
75
+ fileName = `${baseName}.${info.selector}${resExt}`;
73
76
  }
74
77
  segs.push(`${baseName}.${info.selector}${info.extension}`);
75
78
  } else {
76
79
  segs.push(`${baseName}${resExt}`);
80
+ fileName = `${baseName}${resExt}`;
77
81
  }
78
- fileName = `${baseName}${resExt}`;
79
82
  }
80
83
 
81
84
  info.path = `/${segs.join('/')}`;
@@ -94,14 +97,8 @@ export function validatePathInfo(info) {
94
97
  return false;
95
98
  }
96
99
 
97
- // only support empty selector or plain with html
98
- if (info.selector) {
99
- if (info.selector !== 'plain') {
100
- return false;
101
- }
102
- return info.extension === '.html';
103
- }
104
- return true;
100
+ // only support selector for html
101
+ return info.selector === '' || info.extension === '.html';
105
102
  }
106
103
 
107
104
  /**