@adobe/helix-shared-config 2.1.1 → 2.1.2

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
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.1.2](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config@2.1.1...@adobe/helix-shared-config@2.1.2) (2022-06-02)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * allow adding sitemap or languages ([#690](https://github.com/adobe/helix-shared/issues/690)) ([5f095ef](https://github.com/adobe/helix-shared/commit/5f095ef276e1a44a36d9f3168d25ecf1074fa4ad))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.1.1](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config@2.1.0...@adobe/helix-shared-config@2.1.1) (2022-05-23)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-shared-config",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Shared modules of the Helix Project - config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -49,5 +49,5 @@
49
49
  "mocha": "10.0.0",
50
50
  "nock": "13.2.4"
51
51
  },
52
- "gitHead": "84e3915214c73e1078526b45c7d5116836a62a50"
52
+ "gitHead": "49e92ebcfa348d3cc01782c116d1ca2c42f20c6f"
53
53
  }
@@ -41,6 +41,74 @@ class SitemapConfig extends SchemaDerivedConfig {
41
41
  this._version = this._cfg.version;
42
42
  return this;
43
43
  }
44
+
45
+ /**
46
+ * Adds a sitemap definition.
47
+ *
48
+ * @param {Object} sitemap sitemap configuration
49
+ * @param {string} sitemap.name sitemap name
50
+ * @param {string} sitemap.origin sitemap origin
51
+ * @param {string} sitemap.source sitemap source
52
+ * @param {string} sitemap.destination sitemap destination
53
+ * @param {string} sitemap.lastmod lastmod format
54
+ * @return new sitemap
55
+ */
56
+ addSitemap({
57
+ name, origin, source, destination, lastmod,
58
+ }) {
59
+ const { sitemaps } = this._cfg;
60
+ if (sitemaps[name]) {
61
+ throw new Error(`Unable to add sitemap definition with existing name: ${name}`);
62
+ }
63
+ sitemaps[name] = {
64
+ origin,
65
+ source,
66
+ destination,
67
+ lastmod,
68
+ };
69
+
70
+ // let BaseConfig.toYAML() use the JSON output
71
+ this._document = null;
72
+ return sitemaps[name];
73
+ }
74
+
75
+ /**
76
+ * Adds a language definition within a sitemap.
77
+ *
78
+ * @param {string} sitemapName sitemap name
79
+ * @param {Object} language language configuration
80
+ * @param {string} language.name language name
81
+ * @param {string} language.source language source
82
+ * @param {string} language.destination language destination
83
+ * @param {string} language.hreflang href language
84
+ * @param {string} language.alternate alternate location of this language
85
+ * @return new language
86
+ */
87
+ addLanguage(sitemapName, {
88
+ name, source, destination, hreflang, alternate,
89
+ }) {
90
+ const { sitemaps } = this._cfg;
91
+
92
+ const sitemap = sitemaps[sitemapName];
93
+ if (!sitemap) {
94
+ throw new Error(`Unable to add language, sitemap not found: ${sitemapName}`);
95
+ }
96
+ // eslint-disable-next-line no-multi-assign
97
+ const languages = (sitemap.languages = sitemap.languages || {});
98
+ if (languages[name]) {
99
+ throw new Error(`Unable to add language definition with existing name: ${name}`);
100
+ }
101
+ languages[name] = {
102
+ source,
103
+ destination,
104
+ hreflang,
105
+ alternate,
106
+ };
107
+
108
+ // let BaseConfig.toYAML() use the JSON output
109
+ this._document = null;
110
+ return languages[name];
111
+ }
44
112
  }
45
113
 
46
114
  module.exports = SitemapConfig;