@adobe/helix-config 2.7.1 → 2.8.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
+ # [2.8.0](https://github.com/adobe/helix-config/compare/v2.7.1...v2.8.0) (2024-04-24)
2
+
3
+
4
+ ### Features
5
+
6
+ * add support for robots.txt ([#57](https://github.com/adobe/helix-config/issues/57)) ([dedfec3](https://github.com/adobe/helix-config/commit/dedfec38c0ff97953b71ea3d71a4547f981eb56d)), closes [#56](https://github.com/adobe/helix-config/issues/56)
7
+
1
8
  ## [2.7.1](https://github.com/adobe/helix-config/compare/v2.7.0...v2.7.1) (2024-04-24)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "description": "Helix Config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -66,6 +66,19 @@ async function fetchConfigAll(ctx, contentBusId, partition) {
66
66
  return res.json();
67
67
  }
68
68
 
69
+ /**
70
+ * Retrieves the robots.txt from the code-bus
71
+ * @param {ConfigContext} ctx the context
72
+ * @param {string} owner
73
+ * @param {string} repo
74
+ * @returns {Promise<string|null>} the robots.txt
75
+ */
76
+ export async function fetchRobotsTxt(ctx, owner, repo) {
77
+ const key = `${owner}/${repo}/main/robots.txt`;
78
+ const res = await ctx.loader.getObject(HELIX_CODE_BUS, key);
79
+ return res.body;
80
+ }
81
+
69
82
  /**
70
83
  * Loads the content from a helix 4 project.
71
84
  * @param {ConfigContext} ctx
@@ -131,6 +144,12 @@ export async function resolveLegacyConfig(ctx, rso, scope) {
131
144
  if (configAllLive?.metadata) {
132
145
  config.metadata.live = configAllLive.metadata;
133
146
  }
147
+ const robots = await fetchRobotsTxt(ctx, rso.org, rso.site);
148
+ if (robots) {
149
+ config.robots = {
150
+ txt: robots,
151
+ };
152
+ }
134
153
  }
135
154
  return config;
136
155
  }
@@ -18,7 +18,7 @@ import {
18
18
  SCOPE_DELIVERY,
19
19
  SCOPE_RAW,
20
20
  } from './ConfigContext.js';
21
- import { resolveLegacyConfig } from './config-legacy.js';
21
+ import { resolveLegacyConfig, fetchRobotsTxt } from './config-legacy.js';
22
22
 
23
23
  /**
24
24
  * @typedef Config
@@ -167,6 +167,12 @@ async function resolveConfig(ctx, rso, scope) {
167
167
  preview: await loadMetadata(ctx, config, 'preview'),
168
168
  live: await loadMetadata(ctx, config, 'live'),
169
169
  };
170
+ if (!config.robots) {
171
+ const txt = await fetchRobotsTxt(ctx, config.code.owner, config.code.repo);
172
+ if (txt) {
173
+ config.robots = { txt };
174
+ }
175
+ }
170
176
  }
171
177
  if (scope === SCOPE_PIPELINE || scope === SCOPE_DELIVERY) {
172
178
  config.head = await loadHeadHtml(ctx, config, rso.ref);
@@ -254,6 +260,7 @@ export async function getConfigResponse(ctx, opts) {
254
260
  },
255
261
  };
256
262
  delete adminConfig.public;
263
+ delete adminConfig.robots;
257
264
  return new PipelineResponse(JSON.stringify(adminConfig, null, 2), {
258
265
  headers: {
259
266
  'content-type': 'application/json',
@@ -288,6 +295,7 @@ export async function getConfigResponse(ctx, opts) {
288
295
  cdn: config.cdn,
289
296
  folders: config.folders,
290
297
  public: config.public,
298
+ robots: config.robots,
291
299
  };
292
300
  return new PipelineResponse(JSON.stringify(pipelineConfig, null, 2), {
293
301
  headers: {
@@ -46,6 +46,9 @@
46
46
  },
47
47
  "metadata": {
48
48
  "$ref": "https://ns.adobe.com/helix/config/metadata-source"
49
+ },
50
+ "robots": {
51
+ "$ref": "https://ns.adobe.com/helix/config/robots"
49
52
  }
50
53
  },
51
54
  "required": [
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ module.exports = require('./robots.schema.json');
@@ -0,0 +1,23 @@
1
+ {
2
+ "meta:license": [
3
+ "Copyright 2024 Adobe. All rights reserved.",
4
+ "This file is licensed to you under the Apache License, Version 2.0 (the \"License\");",
5
+ "you may not use this file except in compliance with the License. You may obtain a copy",
6
+ "of the License at http://www.apache.org/licenses/LICENSE-2.0",
7
+ "",
8
+ "Unless required by applicable law or agreed to in writing, software distributed under",
9
+ "the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS",
10
+ "OF ANY KIND, either express or implied. See the License for the specific language",
11
+ "governing permissions and limitations under the License."
12
+ ],
13
+ "$schema": "http://json-schema.org/draft-07/schema#",
14
+ "$id": "https://ns.adobe.com/helix/config/robots",
15
+ "type": "object",
16
+ "title": "robots",
17
+ "properties": {
18
+ "txt": {
19
+ "type": "string"
20
+ }
21
+ },
22
+ "additionalProperties": false
23
+ }
@@ -51,6 +51,9 @@
51
51
  },
52
52
  "metadata": {
53
53
  "$ref": "https://ns.adobe.com/helix/config/metadata-source"
54
+ },
55
+ "robots": {
56
+ "$ref": "https://ns.adobe.com/helix/config/robots"
54
57
  }
55
58
  },
56
59
  "required": [
@@ -36,6 +36,7 @@ const FRAGMENTS = {
36
36
  'access/preview': 'object',
37
37
  'access/live': 'object',
38
38
  public: 'object',
39
+ robots: 'object',
39
40
  },
40
41
  };
41
42
 
@@ -26,6 +26,7 @@ import markupSchema from '../schemas/content-source-markup.schema.cjs';
26
26
  import metadataSchema from '../schemas/metadata-source.schema.cjs';
27
27
  import onedriveSchema from '../schemas/content-source-onedrive.schema.cjs';
28
28
  import profileSchema from '../schemas/profile.schema.cjs';
29
+ import robotsSchema from '../schemas/robots.schema.cjs';
29
30
  import sidekickSchema from '../schemas/sidekick.schema.cjs';
30
31
  import siteSchema from '../schemas/site.schema.cjs';
31
32
 
@@ -43,6 +44,7 @@ const SCHEMAS = [
43
44
  metadataSchema,
44
45
  onedriveSchema,
45
46
  profileSchema,
47
+ robotsSchema,
46
48
  sidekickSchema,
47
49
  siteSchema,
48
50
  ];
@@ -31,6 +31,7 @@ export interface HelixProfileConfig {
31
31
  access?: Access;
32
32
  sidekick?: SidekickConfig;
33
33
  metadata?: Metadata;
34
+ robots?: Robots;
34
35
  }
35
36
  /**
36
37
  * Defines the content bus location and source.
@@ -247,3 +248,6 @@ export interface SidekickPlugin {
247
248
  export interface Metadata {
248
249
  source?: [] | [string];
249
250
  }
251
+ export interface Robots {
252
+ txt?: string;
253
+ }
@@ -34,6 +34,7 @@ export interface HelixSiteConfig {
34
34
  access?: Access;
35
35
  sidekick?: SidekickConfig;
36
36
  metadata?: Metadata;
37
+ robots?: Robots;
37
38
  }
38
39
  /**
39
40
  * Defines the content bus location and source.
@@ -250,3 +251,6 @@ export interface SidekickPlugin {
250
251
  export interface Metadata {
251
252
  source?: [] | [string];
252
253
  }
254
+ export interface Robots {
255
+ txt?: string;
256
+ }