@adobe/helix-html-pipeline 5.3.0 → 5.4.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,10 @@
1
+ # [5.4.0](https://github.com/adobe/helix-html-pipeline/compare/v5.3.0...v5.4.0) (2023-12-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * render static html from code bus ([#471](https://github.com/adobe/helix-html-pipeline/issues/471)) ([a46dab0](https://github.com/adobe/helix-html-pipeline/commit/a46dab0a9a2eb33e146bf5995e801da517389f69))
7
+
1
8
  # [5.3.0](https://github.com/adobe/helix-html-pipeline/compare/v5.2.0...v5.3.0) (2023-12-05)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "5.3.0",
3
+ "version": "5.4.0",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -74,7 +74,7 @@
74
74
  "@markedjs/html-differ": "4.0.2",
75
75
  "@semantic-release/changelog": "6.0.3",
76
76
  "@semantic-release/git": "10.0.1",
77
- "@semantic-release/npm": "11.0.1",
77
+ "@semantic-release/npm": "11.0.2",
78
78
  "c8": "8.0.1",
79
79
  "eslint": "8.55.0",
80
80
  "eslint-import-resolver-exports": "1.0.0-beta.5",
@@ -85,11 +85,11 @@
85
85
  "js-yaml": "4.1.0",
86
86
  "jsdom": "23.0.1",
87
87
  "junit-report-builder": "3.1.0",
88
- "lint-staged": "15.1.0",
88
+ "lint-staged": "15.2.0",
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.8"
92
+ "semantic-release": "22.0.10"
93
93
  },
94
94
  "lint-staged": {
95
95
  "*.js": "eslint",
package/src/html-pipe.js CHANGED
@@ -96,6 +96,11 @@ export async function htmlPipe(state, req) {
96
96
  return res;
97
97
  }
98
98
 
99
+ // force code-bus for .html files
100
+ if (state.info.originalExtension === '.html' && state.info.selector !== 'plain') {
101
+ state.content.sourceBus = 'code';
102
+ }
103
+
99
104
  // ...and apply the folder mapping
100
105
  state.timer?.update('content-fetch');
101
106
  let contentPromise = await fetchContent(state, req, res);
package/src/index.d.ts CHANGED
@@ -22,7 +22,7 @@ export * from './PipelineStatusError';
22
22
  /**
23
23
  * Path Info
24
24
  */
25
- declare interface PathInfo {
25
+ export declare interface PathInfo {
26
26
  /**
27
27
  * Resource path
28
28
  * @example '/express/index.md'
@@ -72,7 +72,7 @@ declare interface PathInfo {
72
72
  unmappedPath: string;
73
73
  }
74
74
 
75
- declare interface S3Loader {
75
+ export declare interface S3Loader {
76
76
  /**
77
77
  * Loads a S3 object from the given bucket and key.
78
78
  * @param {string} bucketId
@@ -88,7 +88,7 @@ declare interface S3Loader {
88
88
  headObject(bucketId, key): Promise<PipelineResponse>;
89
89
  }
90
90
 
91
- declare interface AuthEnvLoader {
91
+ export declare interface AuthEnvLoader {
92
92
 
93
93
  /**
94
94
  * loads (secret) parameters needed for authentication. The parameters are added to the
@@ -98,12 +98,12 @@ declare interface AuthEnvLoader {
98
98
  load(state:PipelineState):Promise<void>;
99
99
  }
100
100
 
101
- declare interface DispatchMessageResponse {
101
+ export declare interface DispatchMessageResponse {
102
102
  messageId:string,
103
103
  requestId:string,
104
104
  }
105
105
 
106
- declare interface FormsMessageDispatcher {
106
+ export declare interface FormsMessageDispatcher {
107
107
  /**
108
108
  * Dispatches the message to the forms queue
109
109
  * @param {object} message
@@ -114,13 +114,13 @@ declare interface FormsMessageDispatcher {
114
114
  /**
115
115
  * Timer
116
116
  */
117
- declare interface PipelineTimer {
117
+ export declare interface PipelineTimer {
118
118
  /**
119
119
  * Records the timestamp of the given `step`
120
120
  */
121
121
  update(step:string): void;
122
122
  }
123
123
 
124
- declare interface PipelineStep {
124
+ export declare interface PipelineStep {
125
125
  async(state: PipelineState, req: PipelineRequest, resp: PipelineResponse): Promise<void>;
126
126
  }
@@ -41,7 +41,7 @@ export default async function fetchContent(state, req, res) {
41
41
  if (redirectLocation) {
42
42
  res.status = 301;
43
43
  res.body = '';
44
- if (redirectLocation.startsWith('/') && state.info.selector === 'plain') {
44
+ if (redirectLocation.startsWith('/') && info.selector === 'plain') {
45
45
  redirectLocation += '.plain.html';
46
46
  }
47
47
  res.headers.set('location', redirectLocation);
package/src/utils/path.js CHANGED
@@ -43,7 +43,7 @@ export function getPathInfo(path) {
43
43
  // path -> web path (no .html, no index)
44
44
  // resourcePath -> content path (.md)
45
45
  let fileName = info.originalFilename;
46
- if (!fileName || fileName === 'index.html' || fileName === 'index.md' || fileName === 'index') {
46
+ if (!fileName || fileName === 'index.md' || fileName === 'index') {
47
47
  // last segment empty or index
48
48
  const lastDot = fileName.lastIndexOf('.');
49
49
  if (lastDot >= 0) {
@@ -62,21 +62,19 @@ export function getPathInfo(path) {
62
62
  info.extension = fileName.substring(lastDot);
63
63
  info.originalExtension = info.extension;
64
64
  const baseName = fileName.substring(0, firstDot);
65
+ if (lastDot !== firstDot) {
66
+ info.selector = fileName.substring(firstDot + 1, lastDot);
67
+ }
65
68
  let resExt = info.extension;
66
- if (resExt === '.md') {
67
- info.extension = '.html';
68
- segs.push(baseName);
69
- } else if (resExt === '.html') {
70
- resExt = '.md';
71
- segs.push(baseName);
69
+ if (info.selector) {
70
+ if (resExt === '.html') {
71
+ // force .plain.html as markdown resources
72
+ resExt = '.md';
73
+ }
74
+ segs.push(`${baseName}.${info.selector}${info.extension}`);
72
75
  } else {
73
76
  segs.push(`${baseName}${resExt}`);
74
77
  }
75
-
76
- if (lastDot !== firstDot) {
77
- info.selector = fileName.substring(firstDot + 1, lastDot);
78
- segs[segs.length - 1] = `${baseName}.${info.selector}${info.extension}`;
79
- }
80
78
  fileName = `${baseName}${resExt}`;
81
79
  }
82
80