@adobe/helix-html-pipeline 6.4.1 → 6.6.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.6.0](https://github.com/adobe/helix-html-pipeline/compare/v6.5.0...v6.6.0) (2024-02-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * speed up pageblock generation ([#542](https://github.com/adobe/helix-html-pipeline/issues/542)) ([34aca92](https://github.com/adobe/helix-html-pipeline/commit/34aca92e2a5161ab720ca1da2687de46f0b0dbf0))
7
+
8
+ # [6.5.0](https://github.com/adobe/helix-html-pipeline/compare/v6.4.1...v6.5.0) (2024-02-09)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * 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)
14
+
15
+
16
+ ### Features
17
+
18
+ * remove source-location surrogate key ([049caf0](https://github.com/adobe/helix-html-pipeline/commit/049caf059530ca11025a3f4b6c9ca50db0e13122))
19
+
1
20
  ## [6.4.1](https://github.com/adobe/helix-html-pipeline/compare/v6.4.0...v6.4.1) (2024-02-08)
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.1",
3
+ "version": "6.6.0",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -54,7 +54,7 @@
54
54
  "hast-util-to-html": "9.0.0",
55
55
  "hast-util-to-string": "3.0.0",
56
56
  "hastscript": "9.0.0",
57
- "jose": "5.2.1",
57
+ "jose": "5.2.2",
58
58
  "lodash.escape": "4.0.1",
59
59
  "mdast-util-to-hast": "13.1.0",
60
60
  "mdast-util-to-string": "4.0.0",
@@ -83,14 +83,14 @@
83
83
  "eslint-plugin-header": "3.1.1",
84
84
  "eslint-plugin-import": "2.29.1",
85
85
  "esmock": "2.6.3",
86
- "husky": "9.0.10",
86
+ "husky": "9.0.11",
87
87
  "js-yaml": "4.1.0",
88
88
  "jsdom": "24.0.0",
89
89
  "junit-report-builder": "3.2.1",
90
- "lint-staged": "15.2.1",
91
- "mocha": "10.2.0",
90
+ "lint-staged": "15.2.2",
91
+ "mocha": "10.3.0",
92
92
  "mocha-multi-reporters": "1.5.1",
93
- "mocha-suppress-logs": "0.4.1",
93
+ "mocha-suppress-logs": "0.5.1",
94
94
  "semantic-release": "22.0.12"
95
95
  },
96
96
  "lint-staged": {
@@ -10,10 +10,11 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  import { h } from 'hastscript';
13
- import { selectAll, select } from 'hast-util-select';
13
+ import { select } from 'hast-util-select';
14
14
  import { toString } from 'hast-util-to-string';
15
+ import { CONTINUE, SKIP, visit } from 'unist-util-visit';
15
16
  import { toBlockCSSClassNames } from './utils.js';
16
- import { replace, childNodes } from '../utils/hast-utils.js';
17
+ import { childNodes } from '../utils/hast-utils.js';
17
18
 
18
19
  /**
19
20
  * Creates a "DIV representation" of a table.
@@ -74,9 +75,11 @@ function tableToDivs($table) {
74
75
  */
75
76
  export default function createPageBlocks({ content }) {
76
77
  const { hast } = content;
77
- selectAll('div > table', hast).forEach(($table) => {
78
- const $div = tableToDivs($table);
79
- // replace child in parent
80
- replace(hast, $table, $div);
78
+ visit(hast, (node, idx, parent) => {
79
+ if (node.tagName === 'table' && parent.tagName === 'div') {
80
+ parent.children[idx] = tableToDivs(node);
81
+ return SKIP;
82
+ }
83
+ return CONTINUE;
81
84
  });
82
85
  }
@@ -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
  }
@@ -9,16 +9,6 @@
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 { EXIT, visit } from 'unist-util-visit';
13
-
14
- export function replace(tree, oldNode, newNode) {
15
- // $table.parentNode.replaceChild($div, $table);
16
- // replace child in parent
17
- visit(tree, oldNode, (node, idx, parent) => {
18
- parent.children[idx] = newNode;
19
- return EXIT;
20
- });
21
- }
22
12
 
23
13
  export function childNodes(node) {
24
14
  return node.children.filter((n) => n.type === 'element');
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
  /**