@adobe/helix-html-pipeline 6.21.6 → 6.23.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,17 @@
1
+ # [6.23.0](https://github.com/adobe/helix-html-pipeline/compare/v6.22.0...v6.23.0) (2025-03-20)
2
+
3
+
4
+ ### Features
5
+
6
+ * **metatdata:** support hreflang x-default ([#848](https://github.com/adobe/helix-html-pipeline/issues/848)) ([30bf798](https://github.com/adobe/helix-html-pipeline/commit/30bf7986bcf37a98242f3229272613a56a78e39b))
7
+
8
+ # [6.22.0](https://github.com/adobe/helix-html-pipeline/compare/v6.21.6...v6.22.0) (2025-03-20)
9
+
10
+
11
+ ### Features
12
+
13
+ * **metadata:** hreflang links ([#847](https://github.com/adobe/helix-html-pipeline/issues/847)) ([fe0ded5](https://github.com/adobe/helix-html-pipeline/commit/fe0ded545b69d8a1157cd5952725a9cc222dcbda))
14
+
1
15
  ## [6.21.6](https://github.com/adobe/helix-html-pipeline/compare/v6.21.5...v6.21.6) (2025-03-16)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-html-pipeline",
3
- "version": "6.21.6",
3
+ "version": "6.23.0",
4
4
  "description": "Helix HTML Pipeline",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -85,7 +85,7 @@
85
85
  "js-yaml": "4.1.0",
86
86
  "jsdom": "26.0.0",
87
87
  "junit-report-builder": "5.1.1",
88
- "lint-staged": "15.4.3",
88
+ "lint-staged": "15.5.0",
89
89
  "mocha": "11.1.0",
90
90
  "mocha-multi-reporters": "1.5.1",
91
91
  "mocha-suppress-logs": "0.5.1",
@@ -17,6 +17,12 @@ import rehypeParse from 'rehype-parse';
17
17
  import { cleanupHeaderValue } from '@adobe/helix-shared-utils';
18
18
  import { contentSecurityPolicyOnAST } from './csp.js';
19
19
 
20
+ function formatLang(lang) {
21
+ return lang
22
+ .replaceAll('_', '-')
23
+ .toLowerCase();
24
+ }
25
+
20
26
  function appendElement($parent, $el) {
21
27
  if ($el) {
22
28
  $parent.children.push($el);
@@ -76,8 +82,19 @@ export default async function render(state, req, res) {
76
82
  continue;
77
83
  }
78
84
  if (name.toLowerCase() === 'html-lang') {
79
- if (/^[a-z]{2}([-_]{1}[a-z]{2})?$/i.test(value)) {
80
- htmlLang = value;
85
+ if (value) {
86
+ htmlLang = formatLang(value);
87
+ }
88
+ // eslint-disable-next-line no-continue
89
+ continue;
90
+ }
91
+ if (name.toLowerCase().startsWith('hreflang-')) {
92
+ const lang = name.substring(9);
93
+ if (lang) {
94
+ appendElement(
95
+ $head,
96
+ createElement('link', 'rel', 'alternate', 'hreflang', formatLang(lang), 'href', value),
97
+ );
81
98
  }
82
99
  // eslint-disable-next-line no-continue
83
100
  continue;